<?php
/**
- * Exception handler for the Horde_Mime class.
+ * Exception handler for the horde/MIME package.
*
* Copyright 2009-2010 The Horde Project (http://www.horde.org/)
*
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer:: class provides an abstracted interface to render
- * MIME data into various formats. It depends on both a set of
- * Horde_Mime_Viewer_* drivers which handle the actual rendering, and a
- * configuration file to map MIME types to drivers.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer
-{
- /**
- * The config array. This array is shared between all instances of
- * Horde_Mime_Viewer.
- *
- * @var array
- */
- static protected $_config = array();
-
- /**
- * The driver cache array. This array is shared between all instances of
- * Horde_Mime_Viewer.
- *
- * @var array
- */
- static protected $_drivercache = array();
-
- /**
- * Attempts to return a concrete Horde_Mime_Viewer_* object based on the
- * MIME type.
- *
- * @param Horde_Mime_Part $mime_part An object with the information to be
- * rendered.
- * @param string $mime_type The MIME type (overrides the value
- * in the MIME part).
- *
- * @return Horde_Mime_Viewer The Horde_Mime_Viewer object, or false on
- * error.
- */
- static final public function factory($mime_part, $mime_type = null)
- {
- if (is_null($mime_type)) {
- $mime_type = $mime_part->getType();
- }
-
- /* Spawn the relevant driver, and return it (or false on failure). */
- if (($ob = self::_getDriver($mime_type, $GLOBALS['registry']->getApp())) &&
- self::_resolveDriver($ob['driver'], $ob['app']) &&
- class_exists($ob['class'])) {
- $conf = array_merge(self::$_config['mime_drivers'][$ob['app']][$ob['driver']], array('_driver' => $ob['driver']));
- return new $ob['class']($mime_part, $conf);
- }
-
- return false;
- }
-
- /**
- * Given a MIME type, this function will return an appropriate icon.
- *
- * @param string $mime_type The MIME type that we need an icon for.
- *
- * @return string The URL to the appropriate icon.
- */
- static final public function getIcon($mime_type)
- {
- $app = $GLOBALS['registry']->getApp();
- $ob = self::_getIcon($mime_type, $app);
-
- if (is_null($ob)) {
- if ($app == 'horde') {
- return null;
- }
-
- $obHorde = self::_getIcon($mime_type, 'horde');
- return is_null($obHorde) ? null : $obHorde['url'];
- } elseif (($ob['match'] !== 0) && ($app != 'horde')) {
- $obHorde = self::_getIcon($mime_type, 'horde');
- if (!is_null($ob['match']) &&
- ($obHorde['match'] < $ob['match'])) {
- return $obHorde['url'];
- }
- }
-
- return $ob['url'];
- }
-
- /**
- * Given a MIME type and an app name, determine which driver can best
- * handle the data.
- *
- * @param string $mime_type MIME type to resolve.
- * @param string $app App in which to search for the driver.
- *
- * @return mixed Returns false if driver could not be found. Otherwise,
- * an array with the following elements:
- * <pre>
- * 'app' - (string) The app containing the driver (e.g. 'horde')
- * 'driver' - (string) Name of driver (e.g. 'enscript')
- * 'exact' - (boolean) Was the driver and exact match?
- * </pre>
- */
- static final protected function _getDriver($mime_type, $app = 'horde')
- {
- $sig = $mime_type . '|' . $app;
- if (isset(self::$_drivercache[$sig])) {
- return self::$_drivercache[$sig];
- }
-
- /* Make sure horde config is loaded. */
- if (empty(self::$_config['mime_drivers']['horde'])) {
- try {
- self::$_config = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'horde');
- } catch (Horde_Exception $e) {
- return false;
- }
- }
-
- /* Make sure app's config is loaded. There is no requirement that
- * an app have a separate config, so ignore any errors. */
- if (($app != 'horde') && empty(self::$_config['mime_drivers'][$app])) {
- try {
- self::$_config = Horde_Array::array_merge_recursive_overwrite(self::$_config, Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), $app));
- } catch (Horde_Exception $e) {}
- }
-
- $driver = '';
- $exact = false;
-
- list($primary_type,) = explode('/', $mime_type, 2);
- $allSub = $primary_type . '/*';
-
- /* If the app doesn't exist in $mime_drivers_map, check for Horde-wide
- * viewers. */
- if (!isset(self::$_config['mime_drivers_map'][$app]) &&
- ($app != 'horde')) {
- return self::_getDriver($mime_type, 'horde');
- }
-
- $dr = isset(self::$_config['mime_drivers'][$app]) ? self::$_config['mime_drivers'][$app] : array();
- $map = self::$_config['mime_drivers_map'][$app];
-
- /* If an override exists for this MIME type, then use that */
- if (isset($map['overrides'][$mime_type])) {
- $driver = $map['overrides'][$mime_type];
- $exact = true;
- } elseif (isset($map['overrides'][$allSub])) {
- $driver = $map['overrides'][$allSub];
- $exact = true;
- } elseif (isset($map['registered'])) {
- /* Iterate through the list of registered drivers, and see if
- * this MIME type exists in the MIME types that they claim to
- * handle. If the driver handles it, then assign it as the
- * rendering driver. If we find a generic handler, keep iterating
- * to see if we can find a specific handler. */
- foreach ($map['registered'] as $val) {
- if (in_array($mime_type, $dr[$val]['handles'])) {
- $driver = $val;
- $exact = true;
- break;
- } elseif (in_array($allSub, $dr[$val]['handles'])) {
- $driver = $val;
- }
- }
- }
-
- /* If this is an application specific app, and an exact match was
- not found, search for a Horde-wide specific driver. Only use the
- Horde-specific driver if it is NOT the 'default' driver AND the
- Horde driver is an exact match. */
- if (!$exact && ($app != 'horde')) {
- $ob = self::_getDriver($mime_type, 'horde');
- if (empty($driver) ||
- (($ob['driver'] != 'default') && $ob['exact'])) {
- $driver = $ob['driver'];
- $app = 'horde';
- }
- }
-
- /* If the 'default' driver exists in this app, fall back to that. */
- if (empty($driver) && self::_resolveDriver('default', $app)) {
- $driver = 'default';
- }
-
- if (empty($driver)) {
- return false;
- }
-
- self::$_drivercache[$sig] = array(
- 'app' => $app,
- 'class' => (($app == 'horde') ? '' : $app . '_') . 'Horde_Mime_Viewer_' . $driver,
- 'driver' => $driver,
- 'exact' => $exact,
- );
-
- return self::$_drivercache[$sig];
- }
-
- /**
- * Given a driver and an application, attempts to load the library file.
- *
- * @param string $driver Driver name.
- * @param string $app Application name.
- *
- * @return boolean True if library file was loaded.
- */
- static final protected function _resolveDriver($driver = 'default',
- $app = 'horde')
- {
- $driver = ucfirst($driver);
-
- $file = ($app == 'horde')
- ? dirname(__FILE__) . '/Viewer/' . $driver . '.php'
- : $GLOBALS['registry']->applications[$app]['fileroot'] . '/lib/Mime/Viewer/' . $driver . '.php';
-
- return require_once $file;
- }
-
- /**
- * Given an input MIME type and app, this function returns the URL of an
- * icon that can be associated with it
- *
- * @param string $mime_type MIME type to get the icon for.
- *
- * @return mixed Null if not found, or an array with the following keys:
- * <pre>
- * 'exact' - (integer) How exact the match is. Null if no match.
- * 0 - 'exact'
- * 1 - 'primary'
- * 2 - 'driver',
- * 3 - 'default'
- * 'url' - (string) URL to an icon, or null if none could be found.
- * </pre>
- */
- static final protected function _getIcon($mime_type, $app = 'horde')
- {
- if (!($ob = self::_getDriver($mime_type, $app))) {
- return null;
- }
- $driver = $ob['driver'];
-
- list($primary_type,) = explode('/', $mime_type, 2);
- $allSub = $primary_type . '/*';
- $ret = null;
-
- /* If the app doesn't exist in $mime_drivers, return now. */
- if (!isset(self::$_config['mime_drivers'][$app])) {
- return null;
- }
-
- $dr = self::$_config['mime_drivers'][$app];
-
- /* If a specific icon for this driver and mimetype is defined,
- then use that. */
- if (isset($dr[$driver]['icons'])) {
- $icondr = $dr[$driver]['icons'];
- $iconList = array($mime_type => 0, $allSub => 1, 'default' => 2);
- foreach ($iconList as $key => $val) {
- if (isset($icondr[$key])) {
- $ret = array('match' => $val, 'url' => $icondr[$key]);
- break;
- }
- }
- }
-
- /* Try to use a default icon if none already obtained. */
- if (is_null($ret['url']) &&
- isset($dr['default']['icons']['default'])) {
- $ret = array('match' => 3, 'url' => $dr['default']['icons']['default']);
- }
-
- if (!is_null($ret)) {
- $ret['url'] = Horde_Themes::img('mime/' . $ret['url'], $app);
- }
-
- return $ret;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Audio class sends audio parts to the browser for
- * handling by the browser, a plugin, or a helper application.
- *
- * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Audio extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $this->_mimepart->getContents(),
- 'status' => array(),
- 'type' => $this->_mimepart->getType()
- )
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Css class renders CSS source as HTML with an effort
- * to remove potentially malicious code.
- *
- * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Css extends Horde_Mime_Viewer_Source
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => true,
- 'raw' => false
- );
-
- /**
- * Attribute preg patterns.
- *
- * @var array
- */
- protected $_attrPatterns = array(
- // Attributes
- '!([-\w]+\s*):!s' => '<span class="attr"">\\1</span>:',
- // Values
- '!:(\s*)(.+?)(\s*;)!s' => ':\\1<span class="value">\\2</span><span class="eol">\\3</span>',
- // URLs
- '!(url\([\'"]?)(.*?)([\'"]?\))!s' => '<span class="url">\\1<span class="file">\\2</span>\\3</span>',
- // Colors
- '!(#[[:xdigit:]]{3,6})!s' => '<span class="color">\\1</span>',
- // Parentheses
- '!({|})!s' => '<span class="parentheses">\\1</span>',
- // Unity
- '!(em|px|%)\b!s' => '<em>\\1</em>'
- );
-
- /**
- * Handles preg patterns.
- *
- * @var array
- */
- protected $_handlesPatterns = array(
- // HTML Tags
- '!\b(body|h\d|a|span|div|acronym|small|strong|em|pre|ul|ol|li|p)\b!s' => '<span class="htag">\\1</span>\\2',
- // IDs
- '!(#[-\w]+)!s' => '<span class="id">\\1</span>',
- // Class
- '!(\.[-\w]+)\b!s' => '<span class="class">\\1</span>',
- // METAs
- '!(:link|:visited|:hover|:active|:first-letter)!s' => '<span class="metac">\\1</span>'
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- $ret = $this->_renderInline();
-
- // Need Horde headers for CSS tags.
- reset($ret);
- Horde::startBuffer();
- require $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc';
- echo $ret[key($ret)]['data'];
- require $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
- $ret[key($ret)]['data'] = Horde::endBuffer();
-
- return $ret;
- }
-
- /**
- * Return the rendered inline version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _renderInline()
- {
- $css = preg_replace_callback('!(}|\*/).*?({|/\*)!s', array($this, '_handles'), htmlspecialchars($this->_mimepart->getContents(), ENT_NOQUOTES));
- $css = preg_replace_callback('!{[^}]*}!s', array($this, '_attributes'), $css);
- $css = preg_replace_callback('!/\*.*?\*/!s', array($this, '_comments'), $css);
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $this->_lineNumber(trim($css)),
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-
- /**
- * TODO
- */
- protected function _comments($matches)
- {
- return '<span class="comment">' .
- preg_replace('!(http://[/\w-.]+)!s', '<a href="\\1">\\1</a>', $matches[0]) .
- '</span>';
- }
-
- /**
- * TODO
- */
- protected function _attributes($matches)
- {
- return preg_replace(array_keys($this->_attrPatterns), array_values($this->_attrPatterns), $matches[0]);
- }
-
- /**
- * TODO
- */
- protected function _handles($matches)
- {
- return preg_replace(array_keys($this->_handlesPatterns), array_values($this->_handlesPatterns), $matches[0]);
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Deb class renders out lists of files in Debian
- * packages by using the dpkg tool to query the package.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Deb extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => true,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Metadata for the current viewer/data.
- *
- * @var array
- */
- protected $_metadata = array(
- 'compressed' => true,
- 'embedded' => false,
- 'forceinline' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- $ret = $this->_renderInfo();
- if (!empty($ret)) {
- reset($ret);
- $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
- }
- return $ret;
- }
-
- /**
- * Return the rendered information about the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _renderInfo()
- {
- /* Check to make sure the viewer program exists. */
- if (!isset($this->_conf['location']) ||
- !file_exists($this->_conf['location'])) {
- return array();
- }
-
- $tmp_deb = Horde::getTempFile('horde_deb');
-
- file_put_contents($tmp_deb, $this->_mimepart->getContents());
-
- $fh = popen($this->_conf['location'] . " -f $tmp_deb 2>&1", 'r');
- while (($rc = fgets($fh, 8192))) {
- $data .= $rc;
- }
- pclose($fh);
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => '<pre>' . htmlspecialchars($data) . '</pre>',
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Default class simply prints out the encapsulated
- * content. It exists as a fallback if no other intelligent rendering
- * mechanism could be used.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Default extends Horde_Mime_Viewer_Driver
-{
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Driver:: class provides the API for specific viewer
- * drivers to extend.
- *
- * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Driver
-{
- /**
- * Viewer configuration.
- *
- * @var array
- */
- protected $_conf = array();
-
- /**
- * The Horde_Mime_Part object to render.
- *
- * @var Horde_Mime_Part
- */
- protected $_mimepart = null;
-
- /**
- * Viewer parameters.
- *
- * @var array
- */
- protected $_params = array();
-
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => false,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Metadata for the current viewer/data.
- *
- * @var array
- */
- protected $_metadata = array(
- // Is the part *data* compressed (not the rendered data)?
- 'compressed' => false,
- // Does this part contain emebedded MIME data?
- 'embedded' => false,
- // Force inline display of this part?
- 'forceinline' => false
- );
-
- /**
- * Constructor.
- *
- * @param Horde_Mime_Part $mime_part Reference to an object with the
- * information to be rendered.
- * @param array $conf Configuration specific to the
- * driver.
- */
- public function __construct($mime_part, $conf = array())
- {
- $this->_mimepart = $mime_part;
- $this->_conf = $conf;
- }
-
- /**
- * Sets the Horde_Mime_Part object for the class.
- *
- * @param Horde_Mime_Part $mime_part The object with the information to
- * be rendered.
- */
- public function setMIMEPart($mime_part)
- {
- $this->_mimepart = $mime_part;
- }
-
- /**
- * Set parameters for use with this object.
- *
- * @param array $params An array of params to add to the internal
- * params list.
- */
- public function setParams($params = array())
- {
- $this->_params = array_merge($this->_params, $params);
- }
-
- /**
- * Return the rendered version of the Horde_Mime_Part object.
- *
- * @param string $mode The mode:
- * <pre>
- * 'full' - A full representation of the MIME part, for use in a view
- * where the output to the browser can be set to the value
- * returned in 'type'. This mode should only return a single
- * MIME ID entry for viewing and should not return any status
- * information.
- * 'inline' - A representation of the MIME part that can be viewed inline
- * on a text/html page that may contain other HTML elements.
- * 'info' - A representation of the MIME part that can be viewed inline
- * on an text/html page that may contain other HTML elements.
- * This view is not a full view, but rather a condensed view of
- * the contents of the MIME part. This view is intended to be
- * displayed to the user with the intention that this MIME part's
- * subparts may also independently be viewed inline.
- * 'raw' - The raw data of the MIME part, generally useful for downloading
- * a part. This view exists in case this raw data needs to be
- * altered in any way.
- * </pre>
- *
- * @return array An array. The keys are the MIME parts that were handled
- * by the driver. The values are either null (which
- * indicates the driver is recommending that this
- * particular MIME ID should not be displayed) or an array
- * with the following keys:
- * <pre>
- * 'data' - (string) The rendered data.
- * 'status' - (array) An array of status information to be displayed to
- * the user. Consists of arrays with the following keys:
- * 'class' - (string) The class to use for display.
- * 'img' - (string) An image to display.
- * 'text' - (array) The text to display.
- * 'type' - (string) The MIME type of the rendered data.
- * </pre>
- */
- public function render($mode)
- {
- switch ($mode) {
- case 'full':
- try {
- return $this->_render();
- } catch (Horde_Exception $e) {
- $error = $e;
- }
- break;
-
- case 'inline':
- try {
- return $this->_renderInline();
- } catch (Horde_Exception $e) {
- $error = $e;
- }
-
- case 'info':
- try {
- return $this->_renderInfo();
- } catch (Horde_Exception $e) {
- $error = $e;
- }
-
- case 'raw':
- try {
- return $this->_renderRaw();
- } catch (Horde_Exception $e) {
- $error = $e;
- }
- }
-
- // TODO: Error handling
- }
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _render()
- {
- $viewer = $this->_getViewer();
- return $viewer
- ? $viewer->render('full')
- : array();
- }
-
- /**
- * Return the rendered inline version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _renderInline()
- {
- $viewer = $this->_getViewer();
- return $viewer
- ? $viewer->render('inline')
- : array();
- }
-
- /**
- * Return the rendered information about the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _renderInfo()
- {
- $viewer = $this->_getViewer();
- return $viewer
- ? $viewer->render('info')
- : array();
- }
-
- /**
- * Return the rendered information about the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _renderRaw()
- {
- $viewer = $this->_getViewer();
- return $viewer
- ? $viewer->render('raw')
- : array();
- }
-
- /**
- * Can this driver render the the data?
- *
- * @param string $mode The mode. Either 'full', 'inline', 'info', or
- * 'raw'.
- *
- * @return boolean True if the driver can render the data for the given
- * view.
- */
- public function canRender($mode)
- {
- $viewer = $this->_getViewer();
- if ($viewer) {
- return $viewer->canRender($mode);
- }
-
- switch ($mode) {
- case 'full':
- case 'info':
- case 'raw':
- return $this->_capability[$mode];
-
- case 'inline':
- return $this->getConfigParam('inline') &&
- ($this->_metadata['forceinline'] ||
- ($this->_capability['inline'] &&
- ($this->_mimepart->getDisposition() != 'attachment')));
-
- default:
- return false;
- }
- }
-
- /**
- * Does this MIME part possibly contain embedded MIME parts?
- *
- * @return boolean True if this driver supports parsing embedded MIME
- * parts.
- */
- public function embeddedMimeParts()
- {
- $viewer = $this->_getViewer();
- return $viewer
- ? $viewer->embeddedMimeParts()
- : $this->_metadata['embedded'];
- }
-
- /**
- * If this MIME part can contain embedded MIME part(s), and those part(s)
- * exist, return a representation of that data.
- *
- * @return mixed A Horde_Mime_Part object representing the embedded data.
- * Returns null if no embedded MIME part(s) exist.
- */
- public function getEmbeddedMimeParts()
- {
- $viewer = $this->_getViewer();
- return $viewer
- ? $viewer->getEmbeddedMimeParts()
- : $this->_getEmbeddedMimeParts();
- }
-
- /**
- * If this MIME part can contain embedded MIME part(s), and those part(s)
- * exist, return a representation of that data.
- *
- * @return mixed A Horde_Mime_Part object representing the embedded data.
- * Returns null if no embedded MIME part(s) exist.
- */
- protected function _getEmbeddedMimeParts()
- {
- return null;
- }
-
- /**
- * Return a configuration parameter for the current viewer.
- *
- * @param string $param The parameter name.
- *
- * @return mixed The value of the parameter; returns null if the
- * parameter doesn't exist.
- */
- public function getConfigParam($param)
- {
- return isset($this->_conf[$param]) ? $this->_conf[$param] : null;
- }
-
- /**
- * Returns the driver name for the current object.
- *
- * @return string The driver name.
- */
- public function getDriver()
- {
- return $this->_conf['_driver'];
- }
-
- /**
- * Returns metadata information on the viewer/data.
- *
- * @param string $data The metadata key.
- *
- * @return mixed The requested information, or null if the key doesn't
- * exist.
- */
- public function getMetadata($data)
- {
- return isset($this->_metadata[$data])
- ? $this->_metadata[$data]
- : null;
- }
-
- /**
- * Return the underlying MIME Viewer for this part.
- *
- * @return mixed A Horde_Mime_Viewer object, or false if not found.
- */
- protected function _getViewer()
- {
- return false;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Enriched class renders out plain text from enriched
- * content tags, ala RFC 1896.
- *
- * By RFC, we must do the minimal conformance measures of: A minimal
- * text/enriched implementation is one that converts "<<" to "<",
- * removes everything between a <param> command and the next balancing
- * </param> removes all other formatting commands (all text enclosed
- * in angle brackets), and outside of <nofill> environments converts
- * any series of n CRLFs to n-1 CRLFs, and converts any lone CRLF
- * pairs to SPACE.
- *
- * We don't qualify as we don't currently track the <nofill>
- * environment, that is we do CRLF conversion even if <nofill> is
- * specified in the text, but we're close at least.
- *
- * Copyright 2001-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Eric Rostetter <eric.rostetter@physics.utexas.edu>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Enriched extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => true,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => '<html><body>' . $this->_toHTML(false) . '</body></html>',
- 'status' => array(),
- 'type' => 'text/html; charset=' . $this->_mimepart->getCharset()
- )
- );
- }
-
- /**
- * Return the rendered inline version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _renderInline()
- {
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => Horde_String::convertCharset($this->_toHTML(true), $this->_mimepart->getCharset()),
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-
- /**
- * Convert the enriched text to HTML.
- *
- * @param string $inline Rendered inline?
- *
- * @return string The HTML-ified version of the MIME part contents.
- */
- protected function _toHTML($inline)
- {
- $text = trim($this->_mimepart->getContents());
- if (!strlen($text)) {
- return array();
- }
-
- // We add space at the beginning and end of the string as it will
- // make some regular expression checks later much easier (so we
- // don't have to worry about start/end of line characters)
- $text = ' ' . $text . ' ';
-
- // We need to preserve << tags, so map them to ascii 1 or ascii 255
- // We make the assumption here that there would never be an ascii
- // 1 in an email, which may not be valid, but seems reasonable...
- // ascii 255 would work if for some reason you don't like ascii 1
- // ascii 0 does NOT seem to work for this, though I'm not sure why
- $text = str_replace('<<', chr(1), $text);
-
- // Remove any unrecognized tags in the text (via RFC minimal specs)
- // any tags we just don't want to implement can also be removed here
- // Note that this will remove any html links, but this is intended
- $implementedTags = '<param><bold><italic><underline><fixed><excerpt>' .
- '<smaller><bigger><center><color><fontfamily>' .
- '<flushleft><flushright><flushboth><paraindent>';
- // $unImplementedTags = '<nofill><lang>';
- $text = strip_tags($text, $implementedTags);
-
- // restore the << tags as < tags now...
- $text = str_replace(chr(1), '<<', $text);
- // $text = str_replace(chr(255), '<', $text);
-
- $replace = array(
- // Get color parameters into a more useable format.
- '/<color><param>([\da-fA-F]+),([\da-fA-F]+),([\da-fA-F]+)<\/param>/Uis' => '<color r=\1 g=\2 b=\3>',
- '/<color><param>(red|blue|green|yellow|cyan|magenta|black|white)<\/param>/Uis' => '<color n=\1>',
-
- // Get font family parameters into a more useable format.
- '/<fontfamily><param>(\w+)<\/param>/Uis' => '<fontfamily f=\1>',
-
- /* Just remove any remaining parameters -- we won't use them.
- * Any tags with parameters that we want to implement will have
- * come before this. Someday we hope to use these tags (e.g. for
- * <color><param> tags). */
- '/<param>.*<\/param>/Uis' => '',
-
- /* Single line breaks become spaces, double line breaks are a
- * real break. This needs to do <nofill> tracking to be compliant
- * but we don't want to deal with state at this time, so we fake
- * it some day we should rewrite this to handle <nofill>
- * correctly. */
- '/([^\n])\r\n([^\r])/' => '\1 \2',
- '/(\r\n)\r\n/' => '\1'
- );
- $text = preg_replace(array_keys($replace), array_values($replace), $text);
-
- // We try to protect against bad stuff here.
- $text = @htmlspecialchars($text, ENT_QUOTES, $this->_mimepart->getCharset());
-
- // Now convert the known tags to html. Try to remove any tag
- // parameters to stop people from trying to pull a fast one
- $replace = array(
- '/(?<!<)<bold.*>(.*)<\/bold>/Uis' => '<span style="font-weight: bold">\1</span>',
- '/(?<!<)<italic.*>(.*)<\/italic>/Uis' => '<span style="font-style: italic">\1</span>',
- '/(?<!<)<underline.*>(.*)<\/underline>/Uis' => '<span style="text-decoration: underline">\1</span>'
- );
- $text = preg_replace(array_keys($replace), array_values($replace), $text);
-
- $text = preg_replace_callback('/(?<!<)<color r=([\da-fA-F]+) g=([\da-fA-F]+) b=([\da-fA-F]+)>(.*)<\/color>/Uis', array($this, 'colorize'), $text);
-
- $replace = array(
- '/(?<!<)<color n=(red|blue|green|yellow|cyan|magenta|black|white)>(.*)<\/color>/Uis' => '<span style="color: \1">\2</span>',
- '/(?<!<)<fontfamily>(.*)<\/fontfamily>/Uis' => '\1',
- '/(?<!<)<fontfamily f=(\w+)>(.*)<\/fontfamily>/Uis' => '<span style="font-family: \1">\2</span>',
- '/(?<!<)<smaller.*>/Uis' => '<span style="font-size: smaller">',
- '/(?<!<)<\/smaller>/Uis' => '</span>',
- '/(?<!<)<bigger.*>/Uis' => '<span style="font-size: larger">',
- '/(?<!<)<\/bigger>/Uis' => '</span>',
- '/(?<!<)<fixed.*>(.*)<\/fixed>/Uis' => '<font face="fixed">\1</font>',
- '/(?<!<)<center.*>(.*)<\/center>/Uis' => '<div align="center">\1</div>',
- '/(?<!<)<flushleft.*>(.*)<\/flushleft>/Uis' => '<div align="left">\1</div>',
- '/(?<!<)<flushright.*>(.*)<\/flushright>/Uis' => '<div align="right">\1</div>',
- '/(?<!<)<flushboth.*>(.*)<\/flushboth>/Uis' => '<div align="justify">\1</div>',
- '/(?<!<)<paraindent.*>(.*)<\/paraindent>/Uis' => '<blockquote>\1</blockquote>',
- '/(?<!<)<excerpt.*>(.*)<\/excerpt>/Uis' => '<blockquote>\1</blockquote>'
- );
- $text = preg_replace(array_keys($replace), array_values($replace), $text);
-
- // Replace << with < now (from translated HTML form).
- $text = str_replace('<<', '<', $text);
-
- // Now we remove the leading/trailing space we added at the
- // start.
- $text = preg_replace('/^ (.*) $/s', '\1', $text);
-
- // Make URLs clickable.
- $text = Horde_Text_Filter::filter($text, 'linkurls', array(
- 'callback' => 'Horde::externalUrl'
- ));
-
- /* Wordwrap -- note this could impact on our above RFC compliance *IF*
- * we honored nofill tags (which we don't yet). */
- $text = str_replace(array("\t", ' ', "\n "), array(' ', ' ', "\n "), $text);
-
- if ($text[0] == ' ') {
- $text = ' ' . substr($text, 1);
- }
-
- return '<p class="fixed">' . nl2br($text) . '</p>';
- }
-
- /**
- * TODO
- */
- public function colorize($colors)
- {
- for ($i = 1; $i < 4; $i++) {
- $colors[$i] = sprintf('%02X', round(hexdec($colors[$i]) / 255));
- }
- return '<span style="color: #' . $colors[1] . $colors[2] . $colors[3] . '">' . $colors[4] . '</span>';
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Html class renders out HTML text with an effort to
- * remove potentially malicious code.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @author Jon Parise <jon@horde.org>
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => true,
- 'raw' => false
- );
-
- /**
- * The CSS used to display the phishing warning.
- *
- * @var string
- */
- protected $_phishCss = 'padding: 1px;margin-bottom: 3px;font-size: 90%;border: 1px solid #800;background: #e81222;color: #fff;width: 100%;';
-
- /**
- * Phishing status of last call to _phishingCheck().
- *
- * @var boolean
- */
- protected $_phishWarn = false;
-
- /**
- * Temp array for storing data when parsing the HTML document.
- *
- * @var array
- */
- protected $_tmp = array();
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- $html = $this->_cleanHTML($this->_mimepart->getContents(), array('inline' => false));
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $html['html'],
- 'status' => array(),
- 'type' => $this->_mimepart->getType(true)
- )
- );
- }
-
- /**
- * Return the rendered inline version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _renderInline()
- {
- $html = $this->_cleanHTML($this->_mimepart->getContents(), array('inline' => true));
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => Horde_String::convertCharset($html['data'], $this->_mimepart->getCharset()),
- 'status' => $html['status'],
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-
- /**
- * Filters active content, dereferences external links, detects phishing,
- * etc.
- *
- * @todo Use IP checks from
- * http://lxr.mozilla.org/mailnews/source/mail/base/content/phishingDetector.js.
- *
- * @param string $data The HTML data.
- * @param array $options Additional options:
- * <pre>
- * 'charset' - (string) The charset of $data.
- * DEFAULT: The base part charset.
- * 'inline' - (boolean) Are we viewing inline?
- * DEFAULT: false
- * 'noprefetch' - (boolean) Disable DNS prefetching?
- * DEFAULT: false
- * 'phishing' - (boolean) Do phishing highlighting even if not viewing
- * inline.
- * DEFAULT: false.
- * </pre>
- *
- * @return string The cleaned HTML string.
- */
- protected function _cleanHTML($data, $options = array())
- {
- global $browser;
-
- $strip_style_attributes = (!empty($options['inline']) &&
- (($browser->isBrowser('mozilla') &&
- ($browser->getMajor() == 4)) ||
- $browser->isBrowser('msie')));
-
- $data = Horde_Text_Filter::filter($data, array('cleanhtml', 'xss'), array(
- array(
- 'charset' => isset($options['charset']) ? $options['charset'] : $this->_mimepart->getCharset()
- ),
- array(
- 'noprefetch' => !empty($options['noprefetch']),
- 'return_dom' => true,
- 'strip_styles' => (!empty($options['inline']) || $strip_style_attributes),
- 'strip_style_attributes' => $strip_style_attributes
- )
- ));
-
- $this->_tmp = array(
- 'base' => null,
- 'inline' => !empty($options['inline']),
- 'phish' => ((!empty($options['inline']) || !empty($options['phishing'])) && $this->getConfigParam('phishing_check'))
- );
- $this->_phishWarn = false;
-
- $this->_node($data, $data);
-
- return $data->saveHTML();
- }
-
- /**
- * Process DOM node.
- *
- * @param DOMDocument $doc Document node.
- * @param DOMNode $node Node.
- */
- protected function _node($doc, $node)
- {
- if ($node->hasChildNodes()) {
- foreach ($node->childNodes as $child) {
- if ($child instanceof DOMElement) {
- switch (strtolower($child->tagName)) {
- case 'base':
- /* Deal with <base> tags in the HTML, since they will
- * screw up our own relative paths. */
- if ($this->_tmp['inline'] &&
- $child->hasAttribute('href')) {
- $base = $child->getAttribute('href');
- if (substr($base, -1) != '/') {
- $base .= '/';
- }
-
- $this->_tmp['base'] = $base;
- $child->removeAttribute('href');
- }
- break;
- }
-
- foreach ($child->attributes as $val) {
- /* Attempt to fix paths that were relying on a <base>
- * tag. */
- if (!is_null($this->_tmp['base']) &&
- in_array($val->name, array('href', 'src'))) {
- $child->setAttribute($val->name, $this->_tmp['base'] . ltrim($val->value, '/'));
- }
-
- if ($val->name == 'href') {
- if ($this->_tmp['phish'] &&
- $this->_phishingCheck($val->value, $child->textContent)) {
- $this->_phishWarn = true;
- $child->setAttribute('style', ($child->hasAttribute('style') ? rtrim($child->getAttribute('style'), '; ') . ';' : '') . $this->_phishCss);
- }
-
- /* Try to derefer all external references. */
- $child->setAttribute('href', Horde::externalUrl($val->value));
- }
- }
- }
-
- $this->_nodeCallback($doc, $child);
- $this->_node($doc, $child);
- }
- }
- }
-
- /**
- * Process DOM node (callback).
- *
- * @param DOMDocument $doc Document node.
- * @param DOMNode $node Node.
- */
- protected function _nodeCallback($doc, $node)
- {
- }
-
- /**
- * Check for phishing exploits.
- *
- * @param string $href The HREF value.
- * @param string $text The text value of the link.
- *
- * @return boolean True if phishing is detected.
- */
- protected function _phishingCheck($href, $text)
- {
- /* For phishing, we are checking whether the displayable text URL is
- * the same as the HREF URL. If we can't parse the text URL, then we
- * can't do phishing checks. */
- $text_url = @parse_url($text);
- if (!$text_url) {
- return false;
- }
-
- $href_url = parse_url($href);
-
- /* Only concern ourselves with HTTP and FTP links. */
- if (!isset($href_url['scheme']) ||
- !in_array($href_url['scheme'], array('ftp', 'http', 'https'))) {
- return false;
- }
-
- /* Check for case where text is just the domain name. */
- if (!isset($text_url['host'])) {
- if (!isset($text_url['path']) ||
- !preg_match("/^[^\.\s]+(?:\.[^\.\s]+)+$/", $text_url['path'])) {
- return false;
- }
-
- $text_url['host'] = $text_url['path'];
- }
-
- /* If port exists on link, and text link has scheme or port defined,
- * do extra checks:
- * 1. If port exists on text link, and doesn't match, this is
- * phishing.
- * 2. If port doesn't exist on text link, and port does not match
- * defaults, this is phishing. */
- if (isset($href_url['port']) &&
- (isset($text_url['scheme']) || isset($text_url['port']))) {
- if (!isset($text_url['port'])) {
- switch ($text_url['scheme']) {
- case 'ftp':
- $text_url['port'] = 25;
- break;
-
- case 'http':
- $text_url['port'] = 80;
- break;
-
- case 'https':
- $text_url['port'] = 443;
- break;
- }
- }
-
- if ($href_url['port'] != $text_url['port']) {
- return false;
- }
- }
-
- if (strcasecmp($href_url['host'], $text_url['host']) === 0) {
- return false;
- }
-
- /* Don't consider the link a phishing link if the domain is the same
- * on both links (e.g. adtracking.example.com & www.example.com). */
- $host1 = explode('.', $href_url['host']);
- $host2 = explode('.', $text_url['host']);
-
- return (strcasecmp(implode('.', array_slice($host1, -2)), implode('.', array_slice($host2, -2))) !== 0);
- }
-
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Images class allows images to be displayed.
- *
- * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Constructor.
- *
- * @param Horde_Mime_Part $mime_part Reference to an object with the
- * information to be rendered.
- * @param array $conf Configuration specific to the
- * driver.
- */
- public function __construct($mime_part, $conf = array())
- {
- parent::__construct($mime_part, $conf);
-
- /* TODO: Are there other image types that are compressed? */
- $this->_metadata['compressed'] = in_array($this->_getType(), array('image/gif', 'image/jpeg', 'image/png'));
- }
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $this->_mimepart->getContents(),
- 'status' => array(),
- 'type' => $this->_getType()
- )
- );
- }
-
- /**
- * Return the content-type to use for the image.
- *
- * @return string The content-type of the image.
- */
- protected function _getType()
- {
- $type = $this->_mimepart->getType();
-
- switch ($type) {
- case 'image/pjpeg':
- /* image/jpeg and image/pjpeg *appear* to be the same entity, but
- * Mozilla (for one) don't seem to want to accept the latter. */
- return 'image/jpeg';
-
- case 'image/x-png':
- /* image/x-png == image/png. */
- return 'image/png';
-
- default:
- return $type;
- }
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Msexcel class renders out Microsoft Excel
- * documents in HTML format by using the Gnumeric package.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Msexcel extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- /* Check to make sure the viewer program exists. */
- if (!isset($this->_conf['location']) ||
- !file_exists($this->_conf['location'])) {
- return array();
- }
-
- $tmp_xls = Horde::getTempFile('horde_msexcel');
- $tmp_out = Horde::getTempFile('horde_msexcel');
-
- file_put_contents($tmp_xls, $this->_mimepart->getContents());
- $args = ' -E Gnumeric_Excel:excel_dsf -T Gnumeric_html:html40 ' . $tmp_xls . ' ' . $tmp_out;
-
- exec($this->_conf['location'] . $args);
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => file_get_contents($tmp_out),
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Mspowerpoint class renders out Microsoft Powerpoint
- * documents in HTML format by using the xlHtml package.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Mspowerpoint extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- /* Check to make sure the viewer program exists. */
- if (!isset($this->_conf['location']) ||
- !file_exists($this->_conf['location'])) {
- return array();
- }
-
- $data = '';
- $tmp_ppt = Horde::getTempFile('horde_mspowerpoint');
-
- file_put_contents($tmp_ppt, $this->_mimepart->getContents());
-
- $fh = popen($this->_conf['location'] . " $tmp_ppt 2>&1", 'r');
- while (($rc = fgets($fh, 8192))) {
- $data .= $rc;
- }
- pclose($fh);
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $data,
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Msword class renders out Microsoft Word documents
- * in HTML format by using the AbiWord package.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Msword extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- /* Check to make sure the viewer program exists. */
- if (!isset($this->_conf['location']) ||
- !file_exists($this->_conf['location'])) {
- return array();
- }
-
- $tmp_word = Horde::getTempFile('msword');
- $tmp_output = Horde::getTempFile('msword');
- $tmp_file = str_replace(Horde::getTempDir() . '/', '', $tmp_output);
-
- file_put_contents($tmp_word, $this->_mimepart->getContents());
- $args = ' --to=html --to-name=' . $tmp_output . ' ' . $tmp_word;
-
- exec($this->_conf['location'] . $args);
-
- if (file_exists($tmp_output)) {
- $data = file_get_contents($tmp_output);
- $type = 'text/html';
- } else {
- $data = _("Unable to translate this Word document");
- $type = 'text/plain';
- }
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $data,
- 'status' => array(),
- 'type' => $type . '; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Ooo class renders out OpenOffice.org documents in
- * HTML format.
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Marko Djukic <marko@oblo.com>
- * @author Jan Schneider <jan@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Ooo extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Metadata for the current viewer/data.
- *
- * @var array
- */
- protected $_metadata = array(
- /* At this point assume that the document takes advantage of ZIP
- * compression. */
- 'compressed' => true,
- 'embedded' => false,
- 'forceinline' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _render()
- {
- $has_xslt = Horde_Util::extensionExists('xslt');
- $has_ssfile = function_exists('domxml_xslt_stylesheet_file');
- if (($use_xslt = $has_xslt || $has_ssfile)) {
- $tmpdir = Horde_Util::createTempDir(true);
- }
-
- $fnames = array('content.xml', 'styles.xml', 'meta.xml');
- $tags = array(
- 'text:p' => 'p',
- 'table:table' => 'table border="0" cellspacing="1" cellpadding="0" ',
- 'table:table-row' => 'tr bgcolor="#cccccc"',
- 'table:table-cell' => 'td',
- 'table:number-columns-spanned=' => 'colspan='
- );
-
- $zip = Horde_Compress::factory('zip');
- $list = $zip->decompress($this->_mimepart->getContents(), array('action' => Horde_Compress_Zip::ZIP_LIST));
-
- foreach ($list as $key => $file) {
- if (in_array($file['name'], $fnames)) {
- $content = $zip->decompress($this->_mimepart->getContents(), array(
- 'action' => Horde_Compress_Zip::ZIP_DATA,
- 'info' => $list,
- 'key' => $key
- ));
-
- if ($use_xslt) {
- file_put_contents($tmpdir . $file['name'], $content);
- } elseif ($file['name'] == 'content.xml') {
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => str_replace(array_keys($tags), array_values($tags), $content),
- 'status' => array(),
- 'type' => 'text/html; charset=UTF-8'
- )
- );
- }
- }
- }
-
- if (!Horde_Util::extensionExists('xslt')) {
- return array();
- }
-
- $xsl_file = dirname(__FILE__) . '/Ooo/main_html.xsl';
-
- if ($has_ssfile) {
- /* Use DOMXML */
- $xslt = domxml_xslt_stylesheet_file($xsl_file);
- $dom = domxml_open_file($tmpdir . 'content.xml');
- $result = @$xslt->process($dom, array(
- 'metaFileURL' => $tmpdir . 'meta.xml',
- 'stylesFileURL' => $tmpdir . 'styles.xml',
- 'disableJava' => true)
- );
- $result = $xslt->result_dump_mem($result);
- } else {
- // Use XSLT
- $xslt = xslt_create();
- $result = @xslt_process($xslt, $tmpdir . 'content.xml', $xsl_file, null, null, array(
- 'metaFileURL' => $tmpdir . 'meta.xml',
- 'stylesFileURL' => $tmpdir . 'styles.xml',
- 'disableJava' => true)
- );
- if (!$result) {
- $result = xslt_error($xslt);
- }
- xslt_free($xslt);
- }
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $result,
- 'status' => array(),
- 'type' => 'text/html; charset=UTF-8'
- )
- );
- }
-}
+++ /dev/null
-<!--
-
- The Contents of this file are made available subject to the terms of
- either of the following licenses
-
- - GNU Lesser General Public License Version 2.1
- - Sun Industry Standards Source License Version 1.1
-
- Sun Microsystems Inc., October, 2000
-
- GNU Lesser General Public License Version 2.1
- =============================================
- Copyright 2000 by Sun Microsystems, Inc.
- 901 San Antonio Road, Palo Alto, CA 94303, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License version 2.1, as published by the Free Software Foundation.
-
- 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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
-
-
- Sun Industry Standards Source License Version 1.1
- =================================================
- The contents of this file are subject to the Sun Industry Standards
- Source License Version 1.1 (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.openoffice.org/license.html.
-
- Software provided under this License is provided on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- See the License for the specific provisions governing your rights and
- obligations concerning the Software.
-
- The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-
- Copyright © 2002 by Sun Microsystems, Inc.
-
- All Rights Reserved.
-
- Contributor(s): _______________________________________
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="http://openoffice.org/2000/office"
- xmlns:style="http://openoffice.org/2000/style"
- xmlns:text="http://openoffice.org/2000/text"
- xmlns:table="http://openoffice.org/2000/table"
- xmlns:draw="http://openoffice.org/2000/drawing"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:number="http://openoffice.org/2000/datastyle"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:chart="http://openoffice.org/2000/chart"
- xmlns:dr3d="http://openoffice.org/2000/dr3d"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="http://openoffice.org/2000/form"
- xmlns:script="http://openoffice.org/2000/script"
- office:class="text"
- office:version="1.0"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:meta="http://openoffice.org/2000/meta"
- xmlns:config="http://openoffice.org/2001/config"
- xmlns:help="http://openoffice.org/2000/help"
- xmlns:xt="http://www.jclark.com/xt"
- extension-element-prefixes="xt"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:java="http://xml.apache.org/xslt/java"
- exclude-result-prefixes="java">
-
-
-
- <!-- ************ -->
- <!-- *** body *** -->
- <!-- ************ -->
-
-
- <xsl:template match="/*/office:body">
- <xsl:param name="collectedGlobalData"/>
-
- <!-- isDebugMode-START: only isDebugMode purpose: shows the inlined style attributes of the temporary variable -->
- <xsl:if test="$isDebugMode and not($outputType = 'CSS_HEADER')">
- <xsl:element name="debug_tree_of_styles"><xsl:text>
- </xsl:text><xsl:for-each select="$collectedGlobalData/allstyles/*">
-<xsl:text> </xsl:text><xsl:value-of select="name()"/><xsl:text> = </xsl:text><xsl:value-of select="."/><xsl:text>
- </xsl:text>
- </xsl:for-each>
- </xsl:element>
- </xsl:if>
- <!-- isDebugMode-END -->
-
-
- <!-- not using of 'apply-styles-and-content' as the content table information migth have been added to 'collectedGlobalData' variable -->
- <xsl:apply-templates select="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name -->
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
-
-
- <!-- Usability feature, a link to the Content talbe above all level 1 header -->
- <xsl:if test="$contentTableHeadings">
- <xsl:call-template name="add-child-document-usability-links"/>
- </xsl:if>
-
-
- <xsl:choose>
- <xsl:when test="not($outputType = 'WML') and not($outputType = 'PALM')">
- <xsl:choose>
- <!--If the input document is a global document and embed child documents (links) the transformation of the children will be started as well.
- This is necessary as child documents do not know anything about their embedding into a global document. Chapters of childs
- always start to count by zero instead of continously numbering.
- For this, the chapter numbers of the current document (as a sequence of a global document) is dependent
- of the number of chapter of the same level in preceding documents.
- In case of multiple children, for usability reasons some linking is gonna be offered and the URLs of the content-table,
- preceding and following file have to be given for the transformation.
- -->
- <xsl:when test="/*/@office:class='text-global' and /*/office:body/text:section/text:section-source/@xlink:href">
- <!-- the children will be called later with a modified 'collectedGlobalData' variable -->
- <xsl:call-template name="transform-global-document-and-children">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
-
-
-
- <!-- Usability feature, a link to the Content talbe above all level 1 header -->
- <xsl:if test="$contentTableHeadings">
- <xsl:call-template name="add-child-document-usability-links"/>
- </xsl:if>
-
-
- </xsl:template>
-
-
-
-
- <!-- deactivating default template -->
- <xsl:template match="*"/>
-
-
- <!-- allowing all matched text nodes -->
- <xsl:template match="text()">
-<!-- WML <xsl:value-of select="normalize-space(.)"/> -->
- <xsl:value-of select="."/>
- </xsl:template>
-
-
-
- <!-- ################### -->
- <!-- ### INLINE-TEXT ### -->
- <!-- ################### -->
-
-
- <!-- ****************** -->
- <!-- *** Whitespace *** -->
- <!-- ****************** -->
-
-
- <xsl:template match="text:s">
- <xsl:call-template name="write-breakable-whitespace">
- <xsl:with-param name="whitespaces" select="@text:c"/>
- </xsl:call-template>
- </xsl:template>
-
-
- <!--write the number of 'whitespaces' -->
- <xsl:template name="write-breakable-whitespace">
- <xsl:param name="whitespaces"/>
-
- <!--write two space chars as the normal white space character will be stripped
- and the other is able to break -->
- <xsl:text> </xsl:text>
- <xsl:if test="$whitespaces >= 2">
- <xsl:call-template name="write-breakable-whitespace-2">
- <xsl:with-param name="whitespaces" select="$whitespaces - 1"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
-
-
- <!--write the number of 'whitespaces' -->
- <xsl:template name="write-breakable-whitespace-2">
- <xsl:param name="whitespaces"/>
- <!--write two space chars as the normal white space character will be stripped
- and the other is able to break -->
- <xsl:text> </xsl:text>
- <xsl:if test="$whitespaces >= 2">
- <xsl:call-template name="write-breakable-whitespace">
- <xsl:with-param name="whitespaces" select="$whitespaces - 1"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
-
-
-
-
- <!-- *************** -->
- <!-- *** Textbox *** -->
- <!-- *************** -->
-
- <xsl:template match="draw:text-box">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <!-- or -->
- <!--+++++ HTML 4.0 INLINED WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER' or $outputType = 'CSS_INLINED'">
- <xsl:element name="span">
- <xsl:if test="@fo:min-height | @svg:width">
- <xsl:attribute name="style">
- <xsl:choose>
- <xsl:when test="not(@svg:width)">
- <xsl:text>height: </xsl:text><xsl:value-of select="@fo:min-height"/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test="not(@fo:min-height)">
- <xsl:text>width: </xsl:text><xsl:value-of select="@svg:width"/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>height: </xsl:text><xsl:value-of select="@fo:min-height"/><xsl:text>; </xsl:text>
- <xsl:text>width: </xsl:text><xsl:value-of select="@svg:width"/><xsl:text>; </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:apply-templates select="@draw:name"/>
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <!-- 2DO prove best usage for PALM -->
- <!--+++++ PALM 3.2 SUBSET INLINED WAY +++++-->
- <xsl:when test="$outputType = 'PALM'">
- <xsl:element name="span">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <!-- 2DO prove best usage for WML -->
- <!--+++++ WML / WAP +++++-->
- <xsl:otherwise>
- <!-- no nested p tags in wml1.1 allowed -->
- <xsl:choose>
- <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- ID / NAME of text-box -->
- <xsl:template match="@draw:name">
-
- <xsl:attribute name="id">
- <xsl:value-of select="."/>
- </xsl:attribute>
- </xsl:template>
-
-
-
- <!-- ****************** -->
- <!-- *** Paragraphs *** -->
- <!-- ****************** -->
-
- <xsl:template match="text:p | draw:page">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER'">
- <xsl:element name="p">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
-
- <!--+++++ HTML 4.0 INLINED WAY +++++-->
- <xsl:when test="$outputType = 'CSS_INLINED'">
- <xsl:element name="p">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <!--+++++ PALM 3.2 SUBSET INLINED WAY +++++-->
- <xsl:when test="$outputType = 'PALM'">
- <xsl:choose>
- <!-- in palm paragraphs children of text:list-items are better shown without 'p' tag-->
- <xsl:when test="name(parent::*) = 'text:list-item'">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <!--+++++ WML / WAP +++++-->
- <xsl:otherwise>
- <!-- no nested p tags in wml1.1 allowed -->
- <xsl:choose>
- <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <!-- ***************** -->
- <!-- *** Text Span *** -->
- <!-- ***************** -->
-
- <xsl:template match="text:span">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER'">
- <xsl:element name="span">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
-
- <!--+++++ HTML 4.0 INLINED WAY +++++-->
- <xsl:when test="$outputType = 'CSS_INLINED'">
- <xsl:element name="span">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <!--+++++ PALM 3.2 SUBSET INLINED WAY +++++-->
- <xsl:when test="$outputType = 'PALM'">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <!--+++++ WML / WAP +++++-->
- <xsl:otherwise>
- <!-- no nested p tags in wml1.1 allowed -->
- <xsl:choose>
- <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <!-- **************** -->
- <!-- *** Headings *** -->
- <!-- **************** -->
-
- <xsl:template match="text:h">
- <xsl:param name="collectedGlobalData"/>
-
- <!-- Every heading element will get an unique anchor for its file, from its hiearchy level and name:
- For example: The heading title 'My favorite heading' might get <a name="1+2+2+My+favorite+heading"/> -->
- <xsl:choose>
- <xsl:when test="$disableLinkedTableOfContent or $isJavaDisabled or not($outputType = 'CSS_HEADER')">
- <!-- The URL linking of an table-of-content is due to a bug (cmp. bug id# 102311) not mapped as URL in the XML.
- Linking of the table-of-content can therefore only be archieved by a work-around in HTML -->
- <xsl:call-template name="create-heading">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <!-- necessary as anchor for the content table -->
- <xsl:call-template name="create-heading-anchor">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
-
- <!-- no embedding the orginal header, as an explicit anchor might be already set -->
- <xsl:call-template name="create-heading">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- default matching for header elements -->
- <xsl:template name="create-heading">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER'">
-
- <xsl:variable name="headertyp" select="concat('h', @text:level)"/>
- <xsl:element name="{$headertyp}">
-
- <!-- outline style 'text:min-label-width' is interpreted as a CSS 'margin-left' attribute -->
- <xsl:variable name="min-label" select="$office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/style:properties/@text:min-label-width"/>
- <xsl:if test="$min-label">
- <xsl:attribute name="style"><xsl:text>margin-left:</xsl:text><xsl:value-of select="$min-label"/><xsl:text>;</xsl:text></xsl:attribute>
- </xsl:if>
-
-
- <xsl:attribute name="class"><xsl:value-of select="translate(@text:style-name, '. %()/\', '')"/></xsl:attribute>
-
- <!-- writing out a chapter number if desired (noticable when a corresponding 'text:outline-style' exist -->
- <xsl:if test="string-length($office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@style:num-format) != 0">
-
- <xsl:choose>
- <xsl:when test="$disableLinkedTableOfContent or $isJavaDisabled or not($outputType = 'CSS_HEADER')">
- <!-- the chapter number is the sum of 'text:start-value' and preceding siblings of 'text:h' with the same 'text:level',
- furthermore when the current document is referenced by a global document - as part of a whole sequence of documents -,
- the chapter no. is dependent of the amount of started headers in preceding documents.
- If the 'text:start-value is not set the default value of '1' has to be taken. -->
- <xsl:variable name="startValue" select="$office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@text:start-value"/>
- <xsl:choose>
- <xsl:when test="$startValue">
- <xsl:choose>
- <xsl:when test="@text:level='1'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel1
- + $startValue"/>
- </xsl:when>
- <xsl:when test="@text:level='2'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel2
- + $startValue"/>
- </xsl:when>
- <xsl:when test="@text:level='3'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel3
- + $startValue"/>
- </xsl:when>
- <xsl:when test="@text:level='4'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel4
- + $startValue"/>
- </xsl:when>
- <xsl:when test="@text:level='5'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel5
- + $startValue"/>
- </xsl:when>
- <xsl:when test="@text:level='6'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel6
- + $startValue"/>
- </xsl:when>
- <xsl:when test="@text:level='7'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel7
- + $startValue"/>
- </xsl:when>
- <xsl:when test="@text:level='8'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel8
- + $startValue"/>
- </xsl:when>
- <xsl:when test="@text:level='9'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel9
- + $startValue"/>
- </xsl:when>
- <xsl:when test="@text:level='10'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel10
- + $startValue"/>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="@text:level='1'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel1
- + 1"/>
- </xsl:when>
- <xsl:when test="@text:level='2'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel2
- + 1"/>
- </xsl:when>
- <xsl:when test="@text:level='3'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel3
- + 1"/>
- </xsl:when>
- <xsl:when test="@text:level='4'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel4
- + 1"/>
- </xsl:when>
- <xsl:when test="@text:level='5'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel5
- + 1"/>
- </xsl:when>
- <xsl:when test="@text:level='6'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel6
- + 1"/>
- </xsl:when>
- <xsl:when test="@text:level='7'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel7
- + 1"/>
- </xsl:when>
- <xsl:when test="@text:level='8'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel8
- + 1"/>
- </xsl:when>
- <xsl:when test="@text:level='9'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel9
- + 1"/>
- </xsl:when>
- <xsl:when test="@text:level='10'">
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $precedingChapterLevel10
- + 1"/>
- </xsl:when>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="get-absolute-chapter-no">
- <xsl:with-param name="precedingChapterLevel1" select="$precedingChapterLevel1"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>    </xsl:text>
- </xsl:if>
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
-
- </xsl:element>
- </xsl:when>
-
-
- <!--+++++ HTML 4.0 INLINED WAY +++++-->
- <xsl:when test="$outputType = 'CSS_INLINED'">
- <xsl:variable name="headertyp" select="concat('h', @text:level)"/>
- <xsl:element name="{$headertyp}">
-
- <xsl:apply-templates select="@text:style-name">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
-
- <!-- writing out a chapter number if desired (noticable when a corresponding 'text:outline-style' exist -->
- <xsl:if test="$office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@text:style-name">
-
- <!-- the chapter number is the sum of 'text:start-value' and preceding siblings of 'text:h' with the same 'text:level' -->
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@text:start-value"/>
- <xsl:text>    </xsl:text>
- </xsl:if>
-
- </xsl:element>
- </xsl:when>
-
- <!-- 2DO: add Chapter No. for PALM and WML <-> problem nested apply-templates -->
-
- <!--+++++ PALM 3.2 SUBSET INLINED WAY +++++-->
- <xsl:when test="$outputType = 'PALM'">
- <xsl:variable name="headertyp" select="concat('h', @text:level)"/>
- <xsl:element name="{$headertyp}">
-
-
- <!-- All children content have to be nested in the styles (e.g. <i><b>ANY CONTENT</b></i>)
- for this xsl:apply-templates will be called later / implicit -->
- <xsl:call-template name="create-attribute-ALIGN">
- <!-- getting the css styles for the style name (mapped by style-mapping.xsl) -->
- <xsl:with-param name="styleProperties" select="$collectedGlobalData/allstyles/*[name()=current()/@text:style-name]"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
-
- <!--+++++ WML / WAP +++++-->
- <xsl:otherwise>
- <!-- no nested p tags in wml1.1 allowed -->
- <xsl:choose>
- <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
- <!-- since no header styles exist, an emphasis is used -->
- <xsl:element name="em">
-
- <!-- writing out a chapter number if desired (noticable when a corresponding 'text:outline-style' exist -->
- <xsl:if test="$office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@text:style-name">
-
- <!-- the chapter number is the sum of 'text:start-value' and preceding siblings of 'text:h' with the same 'text:level' -->
- <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
- + $office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@text:start-value"/>
- <xsl:text>    </xsl:text>
- </xsl:if>
-
- <xsl:apply-templates select="@text:style-name">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
-
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <!-- since no header styles exist, an emphasis is used -->
- <xsl:element name="em">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <!-- ************* -->
- <!-- *** Link *** -->
- <!-- ************* -->
-
- <xsl:template match="text:a | draw:a">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:call-template name="create-common-link">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:template>
-
-
- <xsl:template name="create-common-link">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:choose>
- <xsl:when test="not($outputType = 'WML')">
- <xsl:element name="a">
- <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
- <!--<xsl:attribute name="class">ContentLink</xsl:attribute>-->
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <!-- no nested p tags in wml1.1 allowed -->
- <xsl:choose>
- <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
- <xsl:element name="a">
- <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
- <xsl:apply-templates select="descendant::text()"/>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <xsl:element name="a">
- <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
- <xsl:apply-templates select="descendant::text()"/>
- </xsl:element>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
-
-
- <!-- ******************* -->
- <!-- *** Image Link *** -->
- <!-- ******************* -->
-
- <xsl:template match="draw:image">
- <xsl:param name="collectedGlobalData"/>
-
- <!-- NO IMAGES SUPPLIED FOR WAP OR PALM -->
- <xsl:if test="$outputType = 'CSS_HEADER' or $outputType = 'CSS_INLINED'">
-
- <xsl:element name="img">
- <xsl:if test="@svg:width">
- <xsl:attribute name="width">
- <xsl:call-template name="convert2pixel">
- <xsl:with-param name="value" select="@svg:width"/>
- </xsl:call-template>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="@svg:height">
- <xsl:attribute name="height">
- <xsl:call-template name="convert2pixel">
- <xsl:with-param name="value" select="@svg:height"/>
- </xsl:call-template>
- </xsl:attribute>
- </xsl:if>
- <xsl:if test="svg:desc">
- <xsl:attribute name="alt">
- <xsl:value-of select="svg:desc"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:choose>
- <!-- for images jared in open office document -->
- <xsl:when test="contains(@xlink:href, '#Pictures/')">
- <!-- creating an absolute http URL to the packed image file -->
- <xsl:attribute name="src"><xsl:value-of select="concat($jaredRootURL, '/Pictures/', substring-after(@xlink:href, '#Pictures/'), $optionalURLSuffix)"/></xsl:attribute>
- </xsl:when>
-<!-- Due to a XT bug no DOS ':' before DRIVE letter is allowed, it would result in a unkown protoco exception, but a file URL for a DOS
- path needs the DRIVE letter, therefore all relative URLs remain relativ
-
- <xsl:when test="contains(@xlink:href,'//') or (substring(@xlink:href,2,1) = ':') or starts-with(@xlink:href, '/')">
- <xsl:attribute name="src"><xsl:value-of select="@xlink:href"/></xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <!~~ creating a absolute path/URL for the referenced resource ~~>
- <xsl:attribute name="src"><xsl:value-of select="concat($absoluteSourceDirRef, @xlink:href, $optionalURLSuffix)"/></xsl:attribute>
- </xsl:otherwise>
--->
- <xsl:otherwise>
- <xsl:attribute name="src"><xsl:value-of select="@xlink:href"/></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- <!-- adding a line break to make the presentation more even with the OOo view -->
- <xsl:element name="br"/>
- </xsl:if>
- </xsl:template>
-
-
-
- <!-- ******************** -->
- <!-- *** ordered list *** -->
- <!-- ******************** -->
-
- <xsl:template match="text:ordered-list">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER'">
- <xsl:element name="ol">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <!--+++++ HTML 4.0 INLINED WAY +++++-->
- <xsl:when test="$outputType = 'CSS_INLINED'">
- <xsl:element name="ol">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <!--+++++ PALM 3.2 SUBSET AND WAP INLINED WAY +++++-->
- <xsl:when test="$outputType = 'PALM'">
- <xsl:element name="ol">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <!--+++++ WML / WAP +++++-->
- <xsl:otherwise>
- <xsl:choose>
- <!-- simulating content break of capsulated list elements -->
- <xsl:when test="ancestor::text:list-item">
- <xsl:choose>
- <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
- <!-- simulating content break of capsulated list elements -->
- <xsl:element name="br"></xsl:element>
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <!-- simulating content break of capsulated list elements -->
- <xsl:element name="br"></xsl:element>
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <!-- ********************** -->
- <!-- *** unordered list *** -->
- <!-- ********************** -->
-
- <xsl:template match="text:unordered-list">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER'">
- <xsl:element name="ul">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
-
- <!--+++++ HTML 4.0 INLINED WAY +++++-->
- <xsl:when test="$outputType = 'CSS_INLINED'">
- <xsl:element name="ul">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
-
- <!--+++++ PALM 3.2 SUBSET AND WAP INLINED WAY +++++-->
- <xsl:when test="$outputType = 'PALM'">
- <xsl:element name="ul">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
-
- <!--+++++ WML / WAP +++++-->
- <xsl:otherwise>
- <xsl:choose>
- <!-- simulating content break of capsulated list elements -->
- <xsl:when test="ancestor::text:list-item">
- <xsl:choose>
- <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
- <!-- simulating content break of capsulated list elements -->
- <xsl:element name="br"></xsl:element>
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <!-- simulating content break of capsulated list elements -->
- <xsl:element name="br"></xsl:element>
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <!-- ****************** -->
- <!-- *** list item *** -->
- <!-- ****************** -->
-
- <xsl:template match="text:list-item">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER'">
- <xsl:element name="li">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
-
- <!--+++++ HTML 4.0 INLINED WAY +++++-->
- <xsl:when test="$outputType = 'CSS_INLINED'">
- <xsl:element name="li">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
-
- <!--+++++ PALM 3.2 SUBSET AND WAP INLINED WAY +++++-->
- <xsl:when test="$outputType = 'PALM'">
- <xsl:element name="li">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
-
- <!--+++++ WML / WAP +++++-->
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
- <!-- simulating list elements -->
- <xsl:for-each select="ancestor::text:list-item">*</xsl:for-each>
- <xsl:text>* </xsl:text>
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- <!-- list item break simulation (not in a table)-->
- <xsl:if test="not(ancestor::table:table-cell) or following-sibling::text:list-item">
- <xsl:element name="br"/>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <!-- simulating list elements -->
- <xsl:for-each select="ancestor::text:list-item">*</xsl:for-each>
- <xsl:text>* </xsl:text>
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- <!-- list item break simulation (not in a table)-->
- <xsl:if test="not(ancestor::table:table-cell) or following-sibling::text:list-item">
- <xsl:element name="br"/>
- </xsl:if>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <!-- ********************************************** -->
- <!-- *** Text Section (contains: draw:text-box) *** -->
- <!-- ********************************************** -->
-
- <xsl:template match="text:section">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:if test="not(contains(@text:display, 'none'))">
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER'">
- <xsl:element name="span">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <!--+++++ HTML 4.0 INLINED WAY +++++-->
- <xsl:when test="$outputType = 'CSS_INLINED'">
- <xsl:element name="span">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <!--+++++ PALM 3.2 SUBSET INLINED WAY +++++-->
- <xsl:when test="$outputType = 'PALM'">
- <xsl:choose>
- <xsl:when test="name(parent::*) = 'text:list-item'">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <!--+++++ WML / WAP +++++-->
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="not($outputType = 'WML')">
- <xsl:element name="a">
- <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <!-- no nested p tags in wml1.1 allowed -->
- <xsl:choose>
- <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- </xsl:template>
-
-
-
- <xsl:template match="text:line-break">
- <xsl:element name="br"/>
- </xsl:template>
-
-
-<!--
- TABHANDLING PROBLEM: Tabs are possible to be shown in the HTML text file, but will be later stripped as whitespaces.
- To prevent this one way would be the PRE tag which unfortunately ALWAYS result into a line-break. No surrounding NOBR tags help.
-
- <xsl:template match="text:tab-stop">
- <xsl:if test="not(preceding-sibling::text:tab-stop)">
- <xsl:element name="pre"><xsl:text>	</xsl:text><xsl:for-each select="following-sibling::text:tab-stop"><xsl:text>	</xsl:text></xsl:for-each></xsl:element>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="text:tab-stop"><xsl:text>	</xsl:text></xsl:template>
--->
- <!-- HOTFIX: 8 non-breakable-spaces instead of a TAB is a hack sometimes less Tabs are needed and the code more difficult to read -->
- <xsl:template match="text:tab-stop">
- <xsl:call-template name="write-breakable-whitespace">
- <xsl:with-param name="whitespaces" select="8"/>
- </xsl:call-template>
- </xsl:template>
-
- <!-- currently there have to be an explicit call of the style attribute nodes, maybe the attributes nodes have no priority only order relevant-->
- <!-- STRANGE: checked with biorythm.sxc a simple xsl:apply-templates did not recognice the styles. Maybe caused by the template match order? -->
- <xsl:template name="apply-styles-and-content">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:apply-templates select="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name -->
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
-
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:template>
-
-
- <xsl:template match="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name-->
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER'">
- <xsl:attribute name="class"><xsl:value-of select="translate(., '. %()/\', '')"/></xsl:attribute>
- </xsl:when>
-
- <!--+++++ HTML 4.0 INLINED WAY +++++-->
- <xsl:when test="$outputType = 'CSS_INLINED'">
- <xsl:attribute name="style"><xsl:value-of select="$collectedGlobalData/allstyles/*[name()=current()/.]"/></xsl:attribute>
- </xsl:when>
-
- <!--+++++ PALM 3.2 SUBSET INLINED WAY and WML / WAP +++++-->
- <xsl:when test="$outputType = 'PALM' or $outputType = 'WML'">
- <!-- getting the css styles for the style name (mapped by style-mapping.xsl) -->
- <xsl:variable name="styleProperties" select="$collectedGlobalData/allstyles/*[name()=current()/.]"/>
- <!-- changing the context node -->
- <xsl:for-each select="parent::*">
- <xsl:call-template name="create-nested-format-tags">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
-
- <xsl:template match="text:sequence">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:template>
-
-
-</xsl:stylesheet>
+++ /dev/null
- <!--
-
- The Contents of this file are made available subject to the terms of
- either of the following licenses
-
- - GNU Lesser General Public License Version 2.1
- - Sun Industry Standards Source License Version 1.1
-
- Sun Microsystems Inc., October, 2000
-
- GNU Lesser General Public License Version 2.1
- =============================================
- Copyright 2000 by Sun Microsystems, Inc.
- 901 San Antonio Road, Palo Alto, CA 94303, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License version 2.1, as published by the Free Software Foundation.
-
- 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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
-
-
- Sun Industry Standards Source License Version 1.1
- =================================================
- The contents of this file are subject to the Sun Industry Standards
- Source License Version 1.1 (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.openoffice.org/license.html.
-
- Software provided under this License is provided on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- See the License for the specific provisions governing your rights and
- obligations concerning the Software.
-
- The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-
- Copyright © 2002 by Sun Microsystems, Inc.
-
- All Rights Reserved.
-
- Contributor(s): _______________________________________
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="http://openoffice.org/2000/office"
- xmlns:style="http://openoffice.org/2000/style"
- xmlns:text="http://openoffice.org/2000/text"
- xmlns:table="http://openoffice.org/2000/table"
- xmlns:draw="http://openoffice.org/2000/drawing"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:number="http://openoffice.org/2000/datastyle"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:chart="http://openoffice.org/2000/chart"
- xmlns:dr3d="http://openoffice.org/2000/dr3d"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="http://openoffice.org/2000/form"
- xmlns:script="http://openoffice.org/2000/script"
- office:class="text"
- office:version="1.0"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:meta="http://openoffice.org/2000/meta"
- xmlns:config="http://openoffice.org/2001/config"
- xmlns:help="http://openoffice.org/2000/help"
- xmlns:xt="http://www.jclark.com/xt"
- extension-element-prefixes="xt"
- xmlns:urlencoder="http://www.jclark.com/xt/java/java.net.URLEncoder"
- xmlns:sxghelper="http://www.jclark.com/xt/java/com.sun.star.xslt.helper.SxgChildTransformer"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:java="http://xml.apache.org/xslt/java"
- exclude-result-prefixes="java">
-
-
-
-
- <!-- ********************************************** -->
- <!-- *** Global Document - Table of Content *** -->
- <!-- ********************************************** -->
-
-
-
- <xsl:template match="text:table-of-content">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:template>
-
-
-
- <xsl:template match="text:index-body">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:apply-templates mode="content-table">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:template>
-
-
-
- <xsl:template match="text:index-title" mode="content-table">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:template>
-
- <xsl:template match="text:reference-ref">
- <xsl:param name="collectedGlobalData"/>
-
- <!-- Java is needed as we have to encode the relative links (bug#102311) -->
- <xsl:if test="not($isJavaDisabled)">
- <xsl:element name="a">
- <xsl:attribute name="href">
- <xsl:text>#</xsl:text>
- <xsl:call-template name="encode-string">
- <!-- the space has to be normalized,
- otherwise an illegal argument exception will be thrown for XT-->
- <xsl:with-param name="textToBeEncoded" select="@text:ref-name"/>
- </xsl:call-template>
- </xsl:attribute>
-
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
-
- </xsl:element>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="text:reference-mark">
- <xsl:param name="collectedGlobalData"/>
-
- <!-- Java is needed as we have to encode the relative links (bug#102311) -->
- <xsl:if test="not($isJavaDisabled)">
- <xsl:element name="a">
- <xsl:attribute name="name">
- <xsl:call-template name="encode-string">
- <!-- the space has to be normalized,
- otherwise an illegal argument exception will be thrown for XT-->
- <xsl:with-param name="textToBeEncoded" select="@text:name"/>
- </xsl:call-template>
- </xsl:attribute>
-
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
-
- </xsl:element>
- </xsl:if>
- </xsl:template>
-
-
-
- <xsl:template match="text:reference-mark-start">
- <xsl:param name="collectedGlobalData"/>
-
- <!-- Java is needed as we have to encode the relative links (bug#102311) -->
- <xsl:if test="not($isJavaDisabled)">
- <xsl:element name="a">
- <xsl:attribute name="name">
- <xsl:call-template name="encode-string">
- <!-- the space has to be normalized,
- otherwise an illegal argument exception will be thrown for XT-->
- <xsl:with-param name="textToBeEncoded" select="@text:name"/>
- </xsl:call-template>
- </xsl:attribute>
-
- <xsl:variable name="endOfReference">
- <xsl:for-each select="text:reference-mark-end[@name=current()/@text:name]">
- <xsl:value-of select="position()"/>
- </xsl:for-each>
- </xsl:variable>
-
- <xsl:for-each select="following-sibling::*[position() < $endOfReference]">
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:for-each>
- </xsl:element>
- </xsl:if>
- </xsl:template>
-
-
-
-
- <!-- content table link -->
- <xsl:template match="text:a" mode="content-table">
- <xsl:param name="collectedGlobalData"/>
-
-
- <!-- For anchors in content-headers a bug exists (cp. bug id# 102311) and they have to be worked out separately.
- Currently the link used in the content-table of an Office XML (e.g. in the content table as '#7.Some%20Example%20Headline%7Outline')
- is not a valid URL (cp. bug id# 102311). No file destination is specified nor exist any anchor element for these
- links in the Office XML, nor is the chapter no. known in the linked files.
- A workaround for this transformation therefore had to be made. This time-consuming mechanism is disabled by default and
- can be activated by a parameter (i.e. 'disableLinkedTableOfContent'). A creation of an anchor is made for each header element.
- All header titles gonna be encoding to be usable in a relative URL. -->
- <xsl:choose>
- <xsl:when test="$disableLinkedTableOfContent or $isJavaDisabled">
- <xsl:call-template name="create-common-link">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="create-content-table-link">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <xsl:template name="get-absolute-chapter-no">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="precedingChapterLevel1"/>
-
- <xsl:choose>
- <xsl:when test="$globalDocumentRefToCurrentFile">
-
- <xsl:variable name="currentFileHeadingNo">
- <xsl:call-template name="get-current-file-heading-no"/>
- </xsl:variable>
- <xsl:variable name="testResult" select="$contentTableHeadings/heading[$globalDocumentRefToCurrentFile = @file-url][number($currentFileHeadingNo)]"/>
-
- <xsl:call-template name="get-global-heading-no">
- <xsl:with-param name="currentFileHeadingNo" select="translate($testResult/@absolute-chapter-level, '+', '.')"/>
- <xsl:with-param name="precedingChapterLevel1" select="$precedingChapterLevel1"/>
- </xsl:call-template>
-
- </xsl:when>
- <xsl:otherwise>
- <!-- When the chapter is in the global document itself the link has to be relative (e.g. #index) a absolute href does not
- work with the browser. In case of chapter in the global document, the output URL of the global document was taken. -->
- <xsl:variable name="currentFileHeadingNo">
- <xsl:call-template name="get-current-file-heading-no"/>
- </xsl:variable>
- <xsl:variable name="testResult" select="$collectedGlobalData/content-table-headings/heading[$contentTableURL = @file-url][number($currentFileHeadingNo)]"/>
-
- <xsl:call-template name="get-global-heading-no">
- <xsl:with-param name="currentFileHeadingNo" select="translate($testResult/@absolute-chapter-level, '+', '.')"/>
- <xsl:with-param name="precedingChapterLevel1" select="$precedingChapterLevel1"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <xsl:template name="get-current-file-heading-no">
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:get-current-child-heading-no')">
- <xsl:value-of select="sxghelper:get-current-child-heading-no()"/>
- </xsl:when>
- <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getCurrentChildHeadingNo')">
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.getCurrentChildHeadingNo()"/>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
-
- <xsl:template name="get-next-current-file-heading-no">
- <xsl:param name="file"/>
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:get-next-current-child-heading-no')">
- <xsl:value-of select="sxghelper:get-next-current-child-heading-no($file)"/>
- </xsl:when>
- <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getNextCurrentChildHeadingNo')">
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.getNextCurrentChildHeadingNo($file)"/>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
-
- <xsl:template name="get-global-heading-no">
- <xsl:param name="currentFileHeadingNo"/>
- <xsl:param name="precedingChapterLevel1"/>
-
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:get-global-heading-no')">
- <xsl:value-of select="sxghelper:get-global-heading-no(string($currentFileHeadingNo), number($precedingChapterLevel1))"/>
- </xsl:when>
- <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getGlobalHeadingNo')">
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.getGlobalHeadingNo(string($currentFileHeadingNo), number($precedingChapterLevel1))"/>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
-
-
-
- <!-- necessary as anchor for the content table -->
- <xsl:template name="create-heading-anchor">
- <xsl:param name="collectedGlobalData"/>
-
- <!--
- Currently the link used in the Office XML (e.g. in the content table as '#7.Some%20Example%20Headline%7Outline')
- is not a valid URL (cmp. bug id# 102311). No file destination is specified nor exist any anchor element for these
- links in the Office XML.
- Here we are creating an anchor with the space normalized text of this header as potential jump address of the content table -->
-
- <xsl:choose>
- <xsl:when test="$globalDocumentRefToCurrentFile">
-
- <xsl:variable name="currentFileHeadingNo">
- <xsl:call-template name="get-next-current-file-heading-no">
- <xsl:with-param name="file" select="$globalDocumentRefToCurrentFile"/>
- </xsl:call-template>
- </xsl:variable>
-
-
- <xsl:variable name="testResult" select="$contentTableHeadings/heading[$globalDocumentRefToCurrentFile = @file-url][number($currentFileHeadingNo)]"/>
- <xsl:if test="$isDebugMode">
- <xsl:message>Matching child document header No. <xsl:value-of select="$currentFileHeadingNo"/></xsl:message>
- <xsl:message>absolute-chapter-level: <xsl:value-of select="$testResult/@absolute-chapter-level"/></xsl:message>
- <xsl:message>encodedTitle: <xsl:value-of select="$testResult/@encoded-title"/></xsl:message>
- <xsl:message>globalDocumentRefToCurrentFile: <xsl:value-of select="$globalDocumentRefToCurrentFile"/></xsl:message>
- <xsl:message>*** </xsl:message>
- </xsl:if>
-
- <xsl:element name="a">
- <xsl:attribute name="name">
- <xsl:value-of select="$testResult/@absolute-chapter-level"/>
- <xsl:text>+</xsl:text>
- <xsl:value-of select="$testResult/@encoded-title"/>
- </xsl:attribute>
- </xsl:element>
- </xsl:when>
-
- <xsl:otherwise>
- <!-- When the chapter is in the global document itself the link has to be relative (e.g. #index) a absolute href does not
- work with the browser. In case of chapter in the global document, the output URL of the global document was taken. -->
- <xsl:variable name="currentFileHeadingNo">
- <xsl:call-template name="get-next-current-file-heading-no">
- <xsl:with-param name="file" select="$contentTableURL"/>
- </xsl:call-template>
- </xsl:variable>
-
-
- <xsl:variable name="testResult" select="$collectedGlobalData/content-table-headings/heading[$contentTableURL = @file-url][number($currentFileHeadingNo)]"/>
-
- <xsl:if test="$isDebugMode">
- <xsl:message>Matching global document header No. <xsl:value-of select="$currentFileHeadingNo"/></xsl:message>
- <xsl:message>absolute-chapter-level: <xsl:value-of select="$testResult/@absolute-chapter-level"/></xsl:message>
- <xsl:message>encodedTitle: <xsl:value-of select="$testResult/@encoded-title"/></xsl:message>
- <xsl:message>contentTableURL: <xsl:value-of select="$contentTableURL"/></xsl:message>
- <xsl:message>*** </xsl:message>
- </xsl:if>
-
- <xsl:element name="a">
- <xsl:attribute name="name">
- <xsl:value-of select="$testResult/@absolute-chapter-level"/>
- <xsl:text>+</xsl:text>
- <xsl:value-of select="$testResult/@encoded-title"/>
- </xsl:attribute>
- </xsl:element>
-
- </xsl:otherwise>
- </xsl:choose>
-
-
-
-<!--
-
- <xsl:variable name="title" select="normalize-space(.)"/>
- <!~~DON'T WORK <xsl:variable name="title" select="normalize-space(descendant::text())"/> ~~>
- <xsl:choose>
- <xsl:when test="$globalDocumentRefToCurrentFile">
- <xsl:variable name="testResults" select="$contentTableHeadings/heading[$globalDocumentRefToCurrentFile = @file-url][$title = @title][current()/@text:level = @level]"/>
- <xsl:if test="1 < count($testResults)">
- <xsl:message> *** CAUTION: Multiple chapter headings with similar names: </xsl:message>
- <xsl:message> *** Title: <xsl:value-of select="$title"/> Level: <xsl:value-of select="@text:level"/></xsl:message>
- </xsl:if>
-
- <xsl:variable name="encodedTitle" select="$testResults/@encoded-title"/>
- <xsl:choose>
- <xsl:when test="$encodedTitle">
- <xsl:element name="a">
- <xsl:attribute name="name">
- <xsl:value-of select="$encodedTitle"/>
- </xsl:attribute>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <!~~ even when it is not ~~>
- <xsl:variable name="newEncodedTitle">
- <xsl:call-template name="encode-string">
- <!~~ the space has to be normalized,
- otherwise an illegal argument exception will be thrown for XT~~>
- <xsl:with-param name="textToBeEncoded" select="$title"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:element name="a">
- <xsl:attribute name="name">
- <xsl:value-of select="$newEncodedTitle"/>
- </xsl:attribute>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="testResults" select="$collectedGlobalData/content-table-headings/heading[$contentTableURL = @file-url][$title = @title][current()/@text:level = @level]"/>
- <xsl:if test="1 < count($testResults)">
- <xsl:message> *** CAUTION: Multiple chapter headings with similar names: </xsl:message>
- <xsl:message> *** Title: <xsl:value-of select="$title"/> Level: <xsl:value-of select="@text:level"/></xsl:message>
- <xsl:message> *** </xsl:message>
- </xsl:if>
-
- <xsl:variable name="encodedTitle" select="$testResults/@encoded-title"/>
- <xsl:choose>
- <xsl:when test="$encodedTitle">
- <xsl:element name="a">
- <xsl:attribute name="name">
- <xsl:value-of select="$encodedTitle"/>
- </xsl:attribute>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <!~~ even when it is not ~~>
- <xsl:variable name="newEncodedTitle">
- <xsl:call-template name="encode-string">
- <!~~ the space has to be normalized,
- otherwise an illegal argument exception will be thrown for XT~~>
- <xsl:with-param name="textToBeEncoded" select="$title"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:element name="a">
- <xsl:attribute name="name">
- <xsl:value-of select="$newEncodedTitle"/>
- </xsl:attribute>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-
--->
-
- </xsl:template>
-
-
-
-
- <!-- ************************************** -->
- <!-- CREATION OF A CONTENT TABLE LINK -->
- <!-- ************************************** -->
-
-
- <!-- a special behavior of text:a
- (called from the 'text:a' template) -->
-
- <xsl:template name="create-content-table-link">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:choose>
- <xsl:when test="not($outputType = 'WML')">
- <xsl:element name="a">
- <xsl:attribute name="href">
- <xsl:choose>
- <xsl:when test="starts-with(@xlink:href, '#')">
- <xsl:variable name="correctHeading" select="$collectedGlobalData/content-table-headings/heading[current()/@xlink:href = @content-table-id]"/>
-
- <xsl:value-of select="$correctHeading/@out-file-url"/>
- <xsl:text>#</xsl:text>
- <xsl:value-of select="$correctHeading/@absolute-chapter-level"/>
- <xsl:text>+</xsl:text>
- <xsl:value-of select="$correctHeading/@encoded-title"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="create-common-link">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <xsl:call-template name="apply-styles-and-content">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <!-- 2DO: currently no WML support
-
- <!~~ no nested p tags in wml1.1 allowed ~~>
- <xsl:choose>
- <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
- <xsl:element name="a">
- <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
- <xsl:apply-templates select="."/>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="p">
- <xsl:element name="a">
- <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
- <xsl:apply-templates select="."/>
- </xsl:element>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose> -->
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!--
- CREATION OF A HELPER VARIABLE AS WORKAROUND FOR THE CONTENT TABLE ULR BUG
-
-
- As no valid URL from the content table to the child documents exist in the content table,
- a work-around is done:
-
- First two helper variables are being created.
-
- One containing the list of all references of the global document:
- containg all their title,
- for example:
-
- <chapter-ref title="aTitle 1"/>
- <chapter-ref title="aTitle 2"/>
- <chapter-ref title="aTitle 2/>
- <chapter-ref title="aTitle 3/>
-
- The other containing all heading from the child documents linked from the global document.
- The variable 'childrenHeadings' contains their title and the number of preceding similar titles,
- for example:
-
-
- <child file-url="aURL">
- <heading title="aTitle1" level="1">
- <heading title="aTitle2" level="2">
- <heading title="aTitle3" level="1">
- </child>
-
- For each chapter reference from the content table the
-
- by encoding the chapter names of the child document with the java URLEncoder and
- use this as a part of a link. Furthermore for all heading elements a encoded anchor will be created from the heading.
- Last the workaround parses all children documents for this anhor, as there is no distinction of files from the content table entries.
-
- The new added node set to the collectedGlobalData variable concering the content table is written as
-
-
- <content-table-headings content-table-url="aURL_ToTheGeneratedContentTable">
- <heading file-url="aFileURLToTheGeneratedHeading1" level="1">
- <heading file-url="aFileURLToTheGeneratedHeading2" level="2">
- <heading file-url="aFileURLToTheGeneratedHeading1" level="1">
- <heading file-url="aFileURLToTheGeneratedHeading2" level="2">
- </content-table-headings>
-
-
- Preconditions:
- The correct sequence of child documents according to the Content Table is necessary, granted by the office.
- -->
- <xsl:template name="Create-helper-variables-for-Content-Table">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:if test="$isDebugMode"><xsl:message>Creation of global document helper variable for the content table....</xsl:message></xsl:if>
-
- <!-- Here a helper variable of the content table is created, of all chapter-references which point to a child document.
- an 'chapter-ref' element will be created, containg their title and the number of preceding similar titles,
- for example:
-
- <chapter-ref title="aTitle 1"/>
- <chapter-ref title="aTitle 2"/>
- <chapter-ref title="aTitle 2"/>
- <chapter-ref title="aTitle 3"/>
- -->
- <xsl:variable name="chapterRefs-RTF">
- <!-- '/*/' as the flat and the zipped XML file format have different root elements -->
- <xsl:for-each select="/*/office:body/text:table-of-content/text:index-body/text:p/text:a">
- <xsl:variable name="currentTitle" select="normalize-space(string(.))"/>
- <xsl:element name="chapter-ref">
- <xsl:attribute name="title">
- <xsl:value-of select="$currentTitle"/>
- </xsl:attribute>
- <xsl:attribute name="content-table-id">
- <xsl:value-of select="@xlink:href"/>
- </xsl:attribute>
- </xsl:element>
- </xsl:for-each>
- </xsl:variable>
- <xsl:if test="$isDebugMode"><xsl:message>Finished the Creation of global document helper variable for the content table!</xsl:message></xsl:if>
-
-
-
-
- <xsl:if test="$isDebugMode"><xsl:message>Creation of global document helper variable for the child documents....</xsl:message></xsl:if>
- <!-- Here a helper variable of created from the children documents.
- Containg all heading elements from the child documents. Some or all of them are
- chapters referenced by the Global Document.
- The variable contains their title, the level of the heading and the file URL of the child,
- for example:
-
- <heading title="aTitle1" level="1" file-url="aURL1">
- <heading title="aTitle2" level="2" file-url="aURL1">
- <heading title="aTitle3" level="1" file-url="aURL1">
- <heading title="aTitle4" level="1" file-url="aURL2">
- <heading title="aTitle5" level="2" file-url="aURL2">
- <heading title="aTitle2" level="3" file-url="aURL2">
- <heading title="aTitle6" level="3" file-url="aURL2">
- <heading-count>7</heading-count>
- -->
- <xsl:variable name="childrenHeadings-RTF">
- <!-- all headers from children documents will be added -->
- <xsl:apply-templates select="/*/office:body/text:section" mode="creation-of-variable"/>
- </xsl:variable>
- <xsl:if test="$isDebugMode"><xsl:message>Finished the Creation of global document helper variable for the child documents!</xsl:message></xsl:if>
-
-
- <xsl:choose>
- <xsl:when test="function-available('xt:node-set')">
- <xsl:call-template name="Create-global-variable-for-Content-Table">
- <xsl:with-param name="chapterRefs" select="xt:node-set($chapterRefs-RTF)"/>
- <xsl:with-param name="childrenHeadings" select="xt:node-set($childrenHeadings-RTF)"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="function-available('xalan:nodeset')">
- <xsl:call-template name="Create-global-variable-for-Content-Table">
- <xsl:with-param name="chapterRefs" select="xalan:nodeset($chapterRefs-RTF)"/>
- <xsl:with-param name="childrenHeadings" select="xalan:nodeset($childrenHeadings-RTF)"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
-
-
-
- <xsl:template name="Create-global-variable-for-Content-Table">
- <xsl:param name="chapterRefs"/>
- <xsl:param name="childrenHeadings"/>
- <xsl:param name="collectedGlobalData"/>
-
-
- <xsl:if test="$isDebugMode">
- <!-- helper variable collecting all headings from the global document file children-->
- <xsl:for-each select="$childrenHeadings/heading">
- <xsl:message># <xsl:value-of select="position()"/></xsl:message>
- <xsl:message>level: <xsl:value-of select="@level"/></xsl:message>
- <xsl:message>title: <xsl:value-of select="@title"/></xsl:message>
- <xsl:message>encoded-title: <xsl:value-of select="@encoded-title"/></xsl:message>
- <xsl:message>file-url: <xsl:value-of select="@file-url"/></xsl:message>
- <xsl:message>header-no: <xsl:value-of select="@header-no"/></xsl:message>
- <xsl:message>**</xsl:message>
- </xsl:for-each>
- <xsl:message>**</xsl:message>
- <xsl:message>**</xsl:message>
-
- <!-- helper variable collecting all heading references from the content table of the the global document -->
- <xsl:message>childrenHeadings/heading-count: <xsl:value-of select="$childrenHeadings/heading-count"/></xsl:message>
- <xsl:for-each select="$chapterRefs/chapter-ref">
- <xsl:message># <xsl:value-of select="position()"/></xsl:message>
- <xsl:message>title: <xsl:value-of select="@title"/></xsl:message>
- <xsl:message>**</xsl:message>
- </xsl:for-each>
- </xsl:if>
-
-
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:set-heading-no')">
- <xsl:value-of select="sxghelper:set-heading-no(1)"/>
- <xsl:value-of select="sxghelper:set-current-child-no(1)"/>
- <xsl:value-of select="sxghelper:set-current-child-url(string($childrenHeadings/heading/@file-url))"/>
- </xsl:when>
- <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.setHeadingNo')">
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setHeadingNo(1)"/>
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setCurrentChildNo(1)"/>
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setCurrentChildUrl(string($childrenHeadings/heading/@file-ur))"/>
- </xsl:when>
- </xsl:choose>
-
- <xsl:if test="$isDebugMode"><xsl:message>Creating global document variable for chapter relations....</xsl:message></xsl:if>
- <xsl:variable name="contentTableHeadingsGlobalData-RTF">
- <xsl:element name="content-table-headings">
- <!-- all headings are linked from the current global document input file -->
- <xsl:attribute name="content-table-url">
- <xsl:value-of select="$contentTableURL"/>
- </xsl:attribute>
-
- <!-- had to use a for loop, as a recursion ends with an stackoverflow exception after about 600 recursive calls -->
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:get-heading-no')">
- <xsl:for-each select="$chapterRefs/chapter-ref">
- <xsl:call-template name="searchHeadingInChildDocument">
- <xsl:with-param name="chapterRefs" select="$chapterRefs"/>
- <xsl:with-param name="childrenHeadings" select="$childrenHeadings"/>
- <xsl:with-param name="currentChapterRefNo" select="position()"/>
- <xsl:with-param name="currentHeadingNo" select="sxghelper:get-heading-no()"/>
- <xsl:with-param name="currentChildURL" select="sxghelper:get-current-child-url()"/>
- <xsl:with-param name="currentChildNo" select="sxghelper:get-current-child-no()"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:when>
- <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getHeadingNo')">
- <xsl:for-each select="$chapterRefs/chapter-ref">
- <xsl:call-template name="searchHeadingInChildDocument">
- <xsl:with-param name="chapterRefs" select="$chapterRefs"/>
- <xsl:with-param name="childrenHeadings" select="$childrenHeadings"/>
- <xsl:with-param name="currentChapterRefNo" select="position()"/>
- <xsl:with-param name="currentHeadingNo" select="java:com.sun.star.xslt.helper.SxgChildTransformer.getHeadingNo()"/>
- <xsl:with-param name="currentChildURL" select="java:com.sun.star.xslt.helper.SxgChildTransformer.getCurrentChildUrl()"/>
- <xsl:with-param name="currentChildNo" select="java:com.sun.star.xslt.helper.SxgChildTransformer.getCurrentChildNo()"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:when>
- </xsl:choose>
- </xsl:element>
-
- <!-- adding the already exisiting global data environment -->
- <xsl:copy-of select="$collectedGlobalData"/>
- </xsl:variable>
- <xsl:if test="$isDebugMode"><xsl:message>Finished global document variable for chapter relations!</xsl:message></xsl:if>
-
- <xsl:choose>
- <xsl:when test="function-available('xt:node-set')">
- <xsl:call-template name="start-self-and-children-transformation">
- <xsl:with-param name="collectedGlobalData" select="xt:node-set($contentTableHeadingsGlobalData-RTF)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="function-available('xalan:nodeset')">
- <xsl:call-template name="start-self-and-children-transformation">
- <xsl:with-param name="collectedGlobalData" select="xalan:nodeset($contentTableHeadingsGlobalData-RTF)"/>
- </xsl:call-template>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
-
- <xsl:template name="searchHeadingInChildDocument">
- <xsl:param name="chapterRefs"/>
- <xsl:param name="childrenHeadings"/>
- <xsl:param name="currentChapterRefNo"/>
- <xsl:param name="currentHeadingNo"/>
- <xsl:param name="currentChildURL"/>
- <xsl:param name="currentChildNo"/>
-
-
- <xsl:variable name="currentChapterRef" select="$chapterRefs/chapter-ref[$currentChapterRefNo]"/>
- <xsl:variable name="currentChapterID" select="$currentChapterRef/@content-table-id"/>
- <xsl:variable name="currentChapterTitle" select="$currentChapterRef/@title"/>
-
- <xsl:variable name="currentChildHeading" select="$childrenHeadings/heading[$currentHeadingNo]"/>
- <xsl:variable name="headingTitle" select="$currentChildHeading/@title"/>
- <xsl:variable name="headingLevel" select="$currentChildHeading/@level"/>
- <xsl:variable name="headingNo" select="$currentChildHeading/@header-no"/>
- <xsl:variable name="newChildURL" select="$currentChildHeading/@file-url"/>
-
- <xsl:if test="$isDebugMode">
- <xsl:message>*** new heading </xsl:message>
- <xsl:message>currentChapterID: <xsl:value-of select="$currentChapterID"/></xsl:message>
- <xsl:message>currentChapterTitle: <xsl:value-of select="$currentChapterTitle"/></xsl:message>
- <xsl:message>currentChapterID: <xsl:value-of select="$currentChapterID"/></xsl:message>
- <xsl:message>currentHeadingNo: <xsl:value-of select="$currentHeadingNo"/></xsl:message>
- <xsl:message>headingTitle: <xsl:value-of select="$headingTitle"/></xsl:message>
- <xsl:message>headingLevel: <xsl:value-of select="$headingLevel"/></xsl:message>
- <xsl:message>headingNo: <xsl:value-of select="$headingNo"/></xsl:message>
- <xsl:message>newChildURL: <xsl:value-of select="$newChildURL"/></xsl:message>
- </xsl:if>
-
- <xsl:variable name="outFileURL">
- <xsl:choose>
- <xsl:when test="substring-before($newChildURL,'.xml')">
- <xsl:value-of select="concat(substring-before($newChildURL,'.xml'),'.htm')"/>
- </xsl:when>
- <xsl:when test="substring-before($newChildURL,'.sx')">
- <xsl:value-of select="concat(substring-before($newChildURL,'.sx'),'.htm')"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="isChapterHeading" select="$headingTitle = $currentChapterTitle"/>
- <xsl:variable name="isNewFile" select="string($newChildURL) != string($currentChildURL)"/>
-
-
-
-
- <xsl:if test="$isNewFile">
- <!-- reset of the already collected child headers -->
- <xsl:call-template name="calc-chapter-numbers">
- <xsl:with-param name="level" select="0"/>
- </xsl:call-template>
- </xsl:if>
- <xsl:variable name="absoluteChapterLevel">
- <xsl:call-template name="calc-chapter-numbers">
- <xsl:with-param name="level" select="number($headingLevel)"/>
- </xsl:call-template>
- </xsl:variable>
-
-
- <xsl:element name="heading">
- <!-- necessary to as ID from the content table to get the correct heading element (the buggy URL used as ID)-->
- <xsl:attribute name="content-table-id">
- <xsl:choose>
- <xsl:when test="$isChapterHeading">
- <xsl:value-of select="$currentChapterID"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>only a heading, but not a chapter</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <!-- no of the used child, necessary for quick finding of chapters of next file -->
- <xsl:attribute name="child-document-no">
- <xsl:choose>
- <xsl:when test="$isNewFile">
- <xsl:value-of select="$currentChildNo + 1"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$currentChildNo"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <!-- the URL of the child document source, containing the heading -->
- <xsl:attribute name="file-url">
- <xsl:value-of select="$newChildURL"/>
- </xsl:attribute>
- <xsl:attribute name="out-file-url">
- <xsl:value-of select="$outFileURL"/>
- </xsl:attribute>
- <xsl:attribute name="level">
- <xsl:value-of select="$headingLevel"/>
- </xsl:attribute>
- <xsl:attribute name="title">
- <xsl:value-of select="$headingTitle"/>
- </xsl:attribute>
- <xsl:attribute name="encoded-title">
- <xsl:value-of select="$currentChildHeading/@encoded-title"/>
- </xsl:attribute>
- <xsl:attribute name="absolute-chapter-level">
- <xsl:value-of select="$absoluteChapterLevel"/>
- </xsl:attribute>
- </xsl:element>
-
-
- <xsl:choose>
- <xsl:when test="$childrenHeadings/heading-count != $currentHeadingNo">
- <!-- procede as long the list of children isn'nt worked through -->
- <xsl:choose>
- <xsl:when test="$isChapterHeading">
- <!-- global variables have to be set, so the for-each loop can access them -->
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:set-heading-no')">
- <xsl:value-of select="sxghelper:set-heading-no($currentHeadingNo + 1)"/>
- <xsl:if test="$isNewFile">
- <xsl:value-of select="sxghelper:set-current-child-no($currentChildNo + 1)"/>
- <xsl:value-of select="sxghelper:set-current-child-url(string($newChildURL))"/>
- </xsl:if>
- </xsl:when>
- <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.setHeadingNo')">
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setHeadingNo($currentHeadingNo + 1)"/>
- <xsl:if test="$isNewFile">
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setCurrentChildNo($currentChildNo + 1)"/>
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setCurrentChildUrl($newChildURL)"/>
- </xsl:if>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <!-- not a chapter heading, call itself until a chapter ref is found or the end of headings is reached -->
- <xsl:call-template name="searchHeadingInChildDocument">
- <xsl:with-param name="chapterRefs" select="$chapterRefs"/>
- <xsl:with-param name="childrenHeadings" select="$childrenHeadings"/>
- <xsl:with-param name="currentChapterRefNo" select="$currentChapterRefNo"/>
- <xsl:with-param name="currentHeadingNo" select="$currentHeadingNo + 1"/>
- <xsl:with-param name="currentChildURL" select="$currentChildURL"/>
- <xsl:with-param name="currentChildNo" select="$currentChildNo"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:if test="$isDebugMode">
- <xsl:message>All child documents have been walked through without finding the chapter name!</xsl:message>
- <xsl:message> childrenHeadings/heading-count: <xsl:value-of select="$childrenHeadings/heading-count"/></xsl:message>
- <xsl:message> currentHeadingNo: <xsl:value-of select="$currentHeadingNo"/></xsl:message>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
-
-
- <!-- Chapters from the Content Table have currently no anchor to child documents in OOo XML.
- As solution, whenever a a global document every header of the HTML output gets get's an anchor in the Therefore-->
- <xsl:template name="encode-string">
- <xsl:param name="encoding" select="'UTF-8'"/>
- <xsl:param name="textToBeEncoded"/>
-
- <xsl:choose>
- <xsl:when test="function-available('urlencoder:encode')">
- <xsl:value-of select="urlencoder:encode(normalize-space($textToBeEncoded),$encoding)"/>
- </xsl:when>
- <xsl:when test="function-available('java:java.net.URLEncoder.encode')">
- <xsl:value-of select="java:java.net.URLEncoder.encode(string(normalize-space($textToBeEncoded)),string($encoding))"/>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
-
-
-
-
- <!-- ******************************************************************************************************** -->
- <!-- *** TRANSFORMATION OF ALL CHILD DOCUMENTS OF THE GLOBAL DOCUMENTS BY USING A EXTERNAL HELPER CLASS *** -->
- <!-- ******************************************************************************************************** -->
-
-
- <!-- a new element 'contentTableHeadings' will be added to the helper variable the first time a child will be transformed -->
- <xsl:template name="transform-global-document-and-children">
- <xsl:param name="collectedGlobalData"/>
-
-
- <xsl:choose>
- <xsl:when test="$collectedGlobalData/content-table-headings">
- <xsl:call-template name="start-child-transformation">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <!-- The necessary auxiliary variable hasn't build yet.
- This variable gonna store all headers (with chapter numbers) and the URL of their files -->
-
- <xsl:call-template name="Create-helper-variables-for-Content-Table">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
-
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <xsl:template name="start-self-and-children-transformation">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:if test="$isDebugMode">
- <xsl:call-template name="debug-content-table-headings-variable">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
-
- <xsl:message>Parsing the global document...</xsl:message>
- </xsl:if>
-
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
-
-
- <xsl:if test="$isDebugMode"><xsl:message>Parsing the child documents...</xsl:message></xsl:if>
- <xsl:call-template name="start-child-transformation">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
-
- </xsl:template>
-
-
-
-
- <xsl:template name="start-child-transformation">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:if test="$isDebugMode"><xsl:message>Starting the child transformations...</xsl:message></xsl:if>
-
- <!-- As the childs of a global document (with suffix .sxg) do not know anything about their global parent,
- the transformation of global documents children have to be done implizit.
- Otherwise the chapter number of the children will always start with zero, as they do not know anything about the
- proceding chapters.
- Furthermore, they don't have any links about preceeding and following documents and no linking for usability reasons
- could be done. Therefore the children have to be transformed during the transformation of a global (sxg) document -->
- <xsl:if test="$isDebugMode">
- <xsl:choose>
- <xsl:when test="$collectedGlobalData/content-table-headings">
- <xsl:message>Contentable data exists as global data!</xsl:message>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message>No Contentable global data exists!</xsl:message>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-
- <!-- currently this function only works with node-sets from XT -->
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:transform-children')">
- <xsl:message>
- <xsl:value-of select="sxghelper:transform-children( $collectedGlobalData/content-table-headings,
- string($jaredRootURL),
- string($absoluteSourceDirRef),
- string($optionalURLSuffix),
- string($dpi),
- string($outputType),
- $isDebugMode)"/>
- </xsl:message>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message>Java method transformChildren to transform all children of a global document could not be found. Be sure to use the XT processor.</xsl:message>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
-
-
- <!-- ******************************************************************************* -->
- <!-- *** Creation of helper variable of the headings of all children documents *** -->
- <!-- ******************************************************************************* -->
-
-
- <xsl:template match="/*/office:body/text:section" mode="creation-of-variable">
- <xsl:call-template name="getChildRootNode"/>
-
- <!-- after the last child document the global document will be parsed -->
- <xsl:if test="position() = last()">
- <!-- search the global document after all child documents have been searched
-
-ODK PATCH NO INDEX ELEMENT WANTED !! - null pointer exception
- <xsl:call-template name="getPreviousHeaderNo">
- <xsl:with-param name="fileURL" select="$contentTableURL"/>
- <xsl:with-param name="amountOfCurrentHeading" select="count(following-sibling::text:h)"/>
- <xsl:with-param name="nodeToSearchForHeading" select="following-sibling::text:h"/>
- </xsl:call-template>
--->
- <!-- get the overall No of Headers -->
- <xsl:call-template name="getAllHeaderNo"/>
- </xsl:if>
- </xsl:template>
-
-
- <xsl:template name="getChildRootNode">
- <xsl:variable name="fileURL" select="text:section-source/@xlink:href"/>
-
- <xsl:choose>
- <!-- if absolute URL or absolute DOS PATH or absolute Unix path -->
- <xsl:when test="contains($fileURL,'//') or (substring($fileURL,2,1) = ':') or starts-with($fileURL, '/')">
- <xsl:variable name="childRootNode" select="document($fileURL)"/>
- <xsl:call-template name="getPreviousHeaderNo">
- <xsl:with-param name="fileURL" select="$fileURL"/>
- <!-- NO absolute source path will be added as prefix -->
- <xsl:with-param name="amountOfCurrentHeading" select="count($childRootNode/*/office:body/descendant::text:h)"/>
- <xsl:with-param name="nodeToSearchForHeading" select="$childRootNode/*/office:body/descendant::text:h"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="childRootNode" select="document(concat($absoluteSourceDirRef,'/',$fileURL))"/>
- <xsl:call-template name="getPreviousHeaderNo">
- <xsl:with-param name="fileURL" select="$fileURL"/>
- <!-- the absolute source path will be added as prefix -->
- <xsl:with-param name="amountOfCurrentHeading" select="count($childRootNode/*/office:body/descendant::text:h)"/>
- <xsl:with-param name="nodeToSearchForHeading" select="$childRootNode/*/office:body/descendant::text:h"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <xsl:template name="getPreviousHeaderNo">
- <xsl:param name="fileURL"/>
- <xsl:param name="nodeToSearchForHeading"/>
- <xsl:param name="amountOfCurrentHeading"/>
-
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:get-previous-child-documents-heading-count')">
- <xsl:call-template name="addHeadingInfo">
- <xsl:with-param name="nodeToSearchForHeading" select="$nodeToSearchForHeading"/>
- <xsl:with-param name="fileURL" select="$fileURL"/>
- <xsl:with-param name="previousHeader" select="sxghelper:get-previous-child-documents-heading-count($amountOfCurrentHeading)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getPreviousChildDocumentsHeadingCount')">
- <xsl:call-template name="addHeadingInfo">
- <xsl:with-param name="nodeToSearchForHeading" select="$nodeToSearchForHeading"/>
- <xsl:with-param name="fileURL" select="$fileURL"/>
- <xsl:with-param name="previousHeader" select="java:com.sun.star.xslt.helper.SxgChildTransformer.getPreviousChildDocumentsHeadingCount($amountOfCurrentHeading)"/>
- </xsl:call-template>
- </xsl:when>
- </xsl:choose>
-
- </xsl:template>
-
-
- <xsl:template name="addHeadingInfo">
- <xsl:param name="fileURL"/>
- <xsl:param name="previousHeader"/>
- <xsl:param name="nodeToSearchForHeading"/>
-
- <xsl:variable name="previousHeader2" select="number($previousHeader)"/>
- <xsl:for-each select="$nodeToSearchForHeading">
-
- <xsl:variable name="title" select="normalize-space(.)"/>
-
- <xsl:variable name="encodedTitle">
- <xsl:call-template name="encode-string">
- <!-- the space has to be normalized,
- otherwise an illegal argument exception will be thrown for XT-->
- <xsl:with-param name="textToBeEncoded" select="$title"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:element name="heading">
- <!-- odd but 'descendant:text()' didn't work, but '.', to get all text nodes of the header -->
- <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
- <xsl:attribute name="encoded-title"><xsl:value-of select="$encodedTitle"/></xsl:attribute>
- <xsl:attribute name="level"><xsl:value-of select="@text:level"/></xsl:attribute>
- <xsl:attribute name="file-url"><xsl:value-of select="$fileURL"/></xsl:attribute>
- <xsl:attribute name="header-no"><xsl:value-of select="position() + $previousHeader2"/></xsl:attribute>
- </xsl:element>
- </xsl:for-each>
-
- </xsl:template>
-
-
- <xsl:template name="getAllHeaderNo">
-
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:get-all-child-documents-heading-count')">
- <xsl:call-template name="addAllHeaderNoElement">
- <xsl:with-param name="allHeader" select="sxghelper:get-all-child-documents-heading-count()"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getAllChildDocumentsHeadingCount')">
- <xsl:call-template name="addAllHeaderNoElement">
- <xsl:with-param name="allHeader" select="java:com.sun.star.xslt.helper.SxgChildTransformer.getAllChildDocumentsHeadingCount()"/>
- </xsl:call-template>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="addAllHeaderNoElement">
- <xsl:param name="allHeader"/>
-
- <xsl:element name="heading-count">
- <xsl:value-of select="$allHeader"/>
- </xsl:element>
-
- </xsl:template>
-
-
- <!-- ******************************************************************************************************* -->
- <!-- *** Creation of a line of links at the beginning and end of a child document to enhance usability *** -->
- <!-- ******************************************************************************************************* -->
-
- <xsl:template name="add-child-document-usability-links">
- <xsl:element name="center">
- <xsl:element name="small">
- <xsl:text>[ </xsl:text>
-
-
- <xsl:variable name="globalDocumentDir" select="sxghelper:get-global-document-dir()"/>
- <xsl:variable name="currentChildNo" select="number($contentTableHeadings/heading[$globalDocumentRefToCurrentFile = @file-url]/@child-document-no)"/>
- <xsl:variable name="earlierDocURL" select="$contentTableHeadings/heading[($currentChildNo - 1) = @child-document-no]/@out-file-url"/>
-<!--
-<xsl:message>from: <xsl:value-of select="$globalDocumentRefToCurrentFile"/></xsl:message>
-<xsl:message>to: <xsl:value-of select="$earlierDocURL"/></xsl:message>
-<xsl:message>Is: <xsl:call-template name="get-relative-file-ref">
- <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
- <xsl:with-param name="targetFileRef" select="$earlierDocURL"/>
- </xsl:call-template>
-</xsl:message>-->
-
-
- <xsl:if test="$earlierDocURL">
- <xsl:element name="a">
- <xsl:attribute name="href">
- <!-- when the links starts with a '#' it's a link to the Content Table-->
- <xsl:choose>
- <xsl:when test="starts-with($earlierDocURL, '#')">
-
- <xsl:call-template name="get-relative-file-ref">
- <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
- <xsl:with-param name="targetFileRef" select="."/>
- </xsl:call-template>
-<!-- <xsl:value-of select="concat($contentTableURL, $earlierDocURL)"/>-->
- </xsl:when>
- <xsl:otherwise>
-
- <xsl:call-template name="get-relative-file-ref">
- <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
- <xsl:with-param name="targetFileRef" select="$earlierDocURL"/>
- </xsl:call-template>
-<!--
-
- <xsl:value-of select="concat($globalDocumentDir, $earlierDocURL)"/>-->
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:text>Previous document</xsl:text>
- </xsl:element>
-
- <xsl:text> | </xsl:text>
- </xsl:if>
-
- <xsl:element name="a">
- <xsl:attribute name="href">
- <!-- when globalDocumentRefToCurrentFile is unset the current file is the Content Table-->
- <xsl:choose>
- <xsl:when test="$globalDocumentRefToCurrentFile">
- <xsl:variable name="contentTableDir">
- <xsl:call-template name="get-name-of-table-of-content-document"/>
- </xsl:variable>
-
- <xsl:call-template name="get-relative-file-ref">
- <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
- <xsl:with-param name="targetFileRef" select="$contentTableDir"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>#</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
-
-<!-- <xsl:value-of select="$contentTableURL"/>-->
- </xsl:attribute>
- <xsl:text>Content Table</xsl:text>
- </xsl:element>
-
-
- <xsl:variable name="nextDocURL" select="$contentTableHeadings/heading[($currentChildNo + 1) = @child-document-no]/@out-file-url"/>
- <xsl:if test="$nextDocURL">
- <xsl:text> | </xsl:text>
- <xsl:element name="a">
- <xsl:attribute name="href">
- <!-- when the links starts with a '#' it's a link to the Content Table-->
- <xsl:choose>
- <xsl:when test="starts-with($nextDocURL, '#')">
- <xsl:call-template name="get-relative-file-ref">
- <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
- <xsl:with-param name="targetFileRef" select="."/>
- </xsl:call-template>
-<!-- <xsl:value-of select="concat($contentTableURL, $nextDocURL)"/>-->
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="get-relative-file-ref">
- <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
- <xsl:with-param name="targetFileRef" select="$nextDocURL"/>
- </xsl:call-template>
-<!-- <xsl:value-of select="concat($globalDocumentDir, $nextDocURL)"/>-->
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:text>Next document</xsl:text>
- </xsl:element>
- </xsl:if>
- <xsl:text> ]</xsl:text>
- </xsl:element>
- </xsl:element>
- </xsl:template>
-
-
- <xsl:template name="get-relative-file-ref">
- <xsl:param name="sourceFileRef"/>
- <xsl:param name="targetFileRef"/>
-
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:get-relative-file-ref')">
- <xsl:value-of select="sxghelper:get-relative-file-ref(string($sourceFileRef), string($targetFileRef))"/>
- </xsl:when>
- <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getRelativeFileRef')">
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.getRelativeFileRef(string($sourceFileRef), string($targetFileRef))"/>
- </xsl:when>
- </xsl:choose>
-
- </xsl:template>
-
-
- <xsl:template name="get-name-of-table-of-content-document">
-
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:get-name-of-table-of-content-document')">
- <xsl:value-of select="sxghelper:get-name-of-table-of-content-document()"/>
- </xsl:when>
- <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getNameOfTableOfContentDocument')">
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.getNameOfTableOfContentDocument()"/>
- </xsl:when>
- </xsl:choose>
-
- </xsl:template>
-
-
- <xsl:template name="debug-content-table-headings-variable">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:message><xsl:text>**** THE HEADING VARIABLE **** </xsl:text></xsl:message>
- <xsl:message>content-table-url: <xsl:value-of select="collectedGlobalData/content-table-headings/content-table-url"/></xsl:message>
-
- <xsl:for-each select="$collectedGlobalData/content-table-headings/heading">
- <xsl:message><xsl:text>**** new heading: </xsl:text></xsl:message>
- <xsl:message>content-table-id: <xsl:value-of select="@content-table-id"/></xsl:message>
- <xsl:message>child-document-no: <xsl:value-of select="@child-document-no"/></xsl:message>
- <xsl:message>file-url: <xsl:value-of select="@file-url"/></xsl:message>
- <xsl:message>out-file-url: <xsl:value-of select="@out-file-url"/></xsl:message>
- <xsl:message>level: <xsl:value-of select="@level"/></xsl:message>
- <xsl:message>title: <xsl:value-of select="@title"/></xsl:message>
- <xsl:message>encoded-title: <xsl:value-of select="@encoded-title"/></xsl:message>
- <xsl:message>absolute-chapter-level:<xsl:value-of select="@absolute-chapter-level"/></xsl:message>
- </xsl:for-each>
-
- </xsl:template>
-
-
- <!-- To make the headings unique, the absolute heading is added to them
- E.g. The level 1.2.3.4. would result into a 1+2+3+4 string -->
- <xsl:template name="calc-chapter-numbers">
- <xsl:param name="level"/>
-
- <xsl:choose>
- <xsl:when test="function-available('sxghelper:calc-chapter-numbers')">
- <xsl:value-of select="sxghelper:calc-chapter-numbers($level)"/>
- </xsl:when>
- <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.calcChapterNumbers')">
- <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.calcChapterNumbers($level)"/>
- </xsl:when>
- </xsl:choose>
-
- </xsl:template>
-
-
-
-
- <xsl:template match="text:p" mode="content-table">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:variable name="allTabStopStyles" select="$office:automatic-styles/style:style[@style:name = current()/@text:style-name]/style:properties/style:tab-stops"/>
-
- <xsl:element name="table">
- <xsl:attribute name="border">0</xsl:attribute>
- <xsl:attribute name="class"><xsl:value-of select="@text:style-name"/></xsl:attribute>
-<!--
-<xsl:message>*********</xsl:message>
-<xsl:message>Stylename:<xsl:value-of select="@text:style-name"/></xsl:message>
-<xsl:message>position: <xsl:value-of select="count($allTabStopStyles/style:tab-stop)"/></xsl:message>
--->
-
- <xsl:element name="colgroup">
- <xsl:call-template name="create-col-element">
- <xsl:with-param name="lastNodePosition" select="count($allTabStopStyles/style:tab-stop)"/>
- <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
- </xsl:call-template>
- </xsl:element>
-
-
- <!-- all elements before the first tabStop -->
- <xsl:variable name="testNo-RTF">
- <xsl:apply-templates select="node()" mode="cell-content"/>
- </xsl:variable>
-
-
- <xsl:choose>
- <xsl:when test="function-available('xt:node-set')">
- <xsl:variable name="tabNodePositions" select="xt:node-set($testNo-RTF)"/>
- <xsl:element name="tr">
- <xsl:call-template name="create-td-elements">
- <xsl:with-param name="lastNodePosition" select="count($allTabStopStyles/style:tab-stop)"/>
- <xsl:with-param name="position" select="1"/>
- <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
- <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
-
- </xsl:when>
- <xsl:when test="function-available('xalan:nodeset')">
- <xsl:variable name="tabNodePositions" select="xalan:nodeset($testNo-RTF)"/>
- <xsl:element name="tr">
- <xsl:call-template name="create-td-elements">
- <xsl:with-param name="lastNodePosition" select="count($allTabStopStyles/style:tab-stop)"/>
- <xsl:with-param name="position" select="1"/>
- <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
- <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
-
- </xsl:when>
- </xsl:choose>
-
- <!-- <xsl:variable name="tabNodePositions" select="xt:node-set($testNo-RTF)"/>
-
- <xsl:element name="tr">
- <xsl:call-template name="create-td-elements">
- <xsl:with-param name="lastNodePosition" select="count($allTabStopStyles/style:tab-stop)"/>
- <xsl:with-param name="position" select="1"/>
- <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
- <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>-->
-
-
- </xsl:element>
- </xsl:template>
-
-
- <xsl:template name="create-col-element">
- <xsl:param name="lastNodePosition"/>
- <xsl:param name="allTabStopStyles"/>
-
- <xsl:for-each select="$allTabStopStyles/style:tab-stop">
- <xsl:element name="col">
- <xsl:attribute name="style">
- <xsl:text>width: </xsl:text>
- <xsl:call-template name="grap-cell-width">
- <xsl:with-param name="position" select="position()"/>
- <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
- </xsl:call-template>
- </xsl:attribute>
- </xsl:element>
- </xsl:for-each>
-
- </xsl:template>
-<!--
-Scenarios tabstops
-
-1) style:type of style:tab-stop is 'right' and earlier tabStop is not right
- -> Earlier text-nodes and following text-nodes, will be put into an inner table, with two TD first aligned left, with proceding textnodes, the latter aligned right.
-
-2) style:type is 'right' and earlier tabStop is right
- -> following text-nodes, will be put into a right aligned TD
-
-3) style:type is 'non-right' and earlier tabStop 'non-right' as well
- -> put the preceding tab stops into a TD (left aligned is default)
-
-4) first style:type would have no right precedign tabStop
- -> works well with first sceanrios 1 and 3
-
-5) last style:type would be a special case, if it would be left aligned, but this won't happen in our case.. :D
-
-Scenarios unmatched:
-- text:styleposition 'center' will not be matched in our case (effort for nothing), there will be only 'right' and not 'right'
-- If the last tabStop is not from text:stylepostion 'right', the length of the last cell is undefined and a document length must be found.
- Not happens in our global document case. Also the algorithm below would have to be expanded (cp. scenario 5).
-
--->
- <xsl:template name="create-td-elements">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="lastNodePosition"/>
- <xsl:param name="position"/>
- <xsl:param name="allTabStopStyles"/>
- <xsl:param name="tabNodePositions"/>
-<!--
-<xsl:message>++++++++</xsl:message>
-<xsl:message>Position: <xsl:value-of select="$position"/></xsl:message>
-<xsl:message>lastNodePosition: <xsl:value-of select="$lastNodePosition"/></xsl:message>
--->
-
- <xsl:variable name="currentStyleType" select="$allTabStopStyles/style:tab-stop[$position]/@style:type"/>
- <xsl:variable name="earlierStyleType" select="$allTabStopStyles/style:tab-stop[$position - 1]/@style:type"/>
- <xsl:choose>
- <xsl:when test="$currentStyleType = 'right'">
- <xsl:choose>
- <xsl:when test="$earlierStyleType = 'right'">
- <!--
- 2) style:type is 'right' and earlier tabStop is right
- -> following text-nodes, will be put into a right aligned TD -->
- <xsl:element name="td">
- <xsl:attribute name="style">
- <xsl:text>align: right</xsl:text>
- </xsl:attribute>
- <xsl:call-template name="grap-cell-content-before-tab-stop">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="endingTabStopPosition" select="$position + 1"/>
- <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
- <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <!--
- 1) style:type of style:tab-stop is 'right' and earlier tabStop is not right
- -> Earlier text-nodes and following text-nodes, will be put into an inner table, with two TD first aligned left, with proceding textnodes, the latter aligned right.-->
-<!-- valid HTML but browsers make a line break (border=0 and paragraphstyle also missing):
- <xsl:element name="table">
- <xsl:element name="td">
- <xsl:call-template name="grap-cell-content-before-tab-stop">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="endingTabStopPosition" select="$position"/>
- <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
- <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
- </xsl:call-template>
- </xsl:element>
- <xsl:element name="td">
- <xsl:attribute name="style">
- <xsl:text>align: right</xsl:text>
- </xsl:attribute>
- <xsl:call-template name="grap-cell-content-before-tab-stop">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="endingTabStopPosition" select="$position + 1"/>
- <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
- <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:element>
--->
- <xsl:element name="td">
- <xsl:call-template name="grap-cell-content-before-tab-stop">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="endingTabStopPosition" select="$position"/>
- <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
- <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
- </xsl:call-template>
-<!-- ODK FEATURE NO PAGES
- <xsl:element name="td">
- <xsl:attribute name="style">
- <xsl:text>align: right</xsl:text>
- </xsl:attribute>
- <xsl:call-template name="grap-cell-content-before-tab-stop">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="endingTabStopPosition" select="$position + 1"/>
- <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
- <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
- </xsl:call-template>
- </xsl:element> -->
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="$earlierStyleType = 'right'">
- </xsl:when>
- <xsl:otherwise>
- <!--
- 3) style:type is 'non-right' and earlier tabStop 'non-right' as well
- -> put the preceding tab stops into a TD (left aligned is default) -->
- <xsl:element name="td">
- <xsl:call-template name="grap-cell-content-before-tab-stop">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="endingTabStopPosition" select="$position"/>
- <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
- <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:if test="$position != $lastNodePosition">
- <xsl:call-template name="create-td-elements">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
- <xsl:with-param name="position" select="$position + 1"/>
- <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
- <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
-
-
- <xsl:template name="grap-cell-content-before-tab-stop">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="endingTabStopPosition"/>
- <xsl:param name="tabNodePositions"/>
- <xsl:param name="lastNodePosition"/>
-
- <xsl:choose>
- <xsl:when test="$endingTabStopPosition = 1">
- <xsl:apply-templates mode="content-table" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]]">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:when test="$endingTabStopPosition > $lastNodePosition">
- <xsl:apply-templates mode="content-table" select="node()[position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="content-table" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]][position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template mode="content-table" match="text:s">
- <xsl:call-template name="write-breakable-whitespace">
- <xsl:with-param name="whitespaces" select="@text:c"/>
- </xsl:call-template>
- </xsl:template>
-
-
- <xsl:template match="*" mode="cell-content">
-
- <xsl:if test="name() = 'text:tab-stop' or *[name() = 'text:tab-stop']">
- <xsl:element name="tab-stop-node-position">
- <xsl:value-of select="position()"/>
- </xsl:element>
- </xsl:if>
- </xsl:template>
-
-
- <xsl:template name="grap-cell-width">
- <xsl:param name="position"/>
- <xsl:param name="allTabStopStyles"/>
-
- <xsl:variable name="tabStopPosition" select="$allTabStopStyles/style:tab-stop[$position]/@style:position"/>
- <xsl:choose>
- <xsl:when test="contains($tabStopPosition, 'cm')">
- <xsl:call-template name="create-cell-width">
- <xsl:with-param name="width" select="number(substring-before($tabStopPosition,'cm'))"/>
- <xsl:with-param name="unit" select="'cm'"/>
- <xsl:with-param name="position" select="$position - 1"/>
- <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="contains($tabStopPosition, 'in')">
- <xsl:call-template name="create-cell-width">
- <xsl:with-param name="width" select="number(substring-before($tabStopPosition,'in'))"/>
- <xsl:with-param name="unit" select="'in'"/>
- <xsl:with-param name="position" select="$position - 1"/>
- <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="contains($tabStopPosition, 'ch')">
- <xsl:call-template name="create-cell-width">
- <xsl:with-param name="width" select="number(substring-before($tabStopPosition,'ch'))"/>
- <xsl:with-param name="unit" select="'ch'"/>
- <xsl:with-param name="position" select="$position - 1"/>
- <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="contains($tabStopPosition, 'pt')">
- <xsl:call-template name="create-cell-width">
- <xsl:with-param name="width" select="number(substring-before($tabStopPosition,'pt'))"/>
- <xsl:with-param name="unit" select="'pt'"/>
- <xsl:with-param name="position" select="$position - 1"/>
- <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
- </xsl:call-template>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="create-cell-width">
- <xsl:param name="width"/>
- <xsl:param name="unit"/>
- <xsl:param name="position"/>
- <xsl:param name="allTabStopStyles"/>
-
- <xsl:choose>
- <xsl:when test="$position > 1">
- <xsl:call-template name="create-cell-width">
- <xsl:with-param name="width" select="$width - number(substring-before($allTabStopStyles/style:tab-stop[$position]/@style:position,$unit))"/>
- <xsl:with-param name="unit" select="$unit"/>
- <xsl:with-param name="position" select="$position - 1"/>
- <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$position = 1">
- <xsl:value-of select="concat($width - number(substring-before($allTabStopStyles/style:tab-stop[$position]/@style:position,$unit)), $unit)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat($width, $unit)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-</xsl:stylesheet>
\ No newline at end of file
+++ /dev/null
-<!--
-
- The Contents of this file are made available subject to the terms of
- either of the following licenses
-
- - GNU Lesser General Public License Version 2.1
- - Sun Industry Standards Source License Version 1.1
-
- Sun Microsystems Inc., October, 2000
-
- GNU Lesser General Public License Version 2.1
- =============================================
- Copyright 2000 by Sun Microsystems, Inc.
- 901 San Antonio Road, Palo Alto, CA 94303, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License version 2.1, as published by the Free Software Foundation.
-
- 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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
-
-
- Sun Industry Standards Source License Version 1.1
- =================================================
- The contents of this file are subject to the Sun Industry Standards
- Source License Version 1.1 (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.openoffice.org/license.html.
-
- Software provided under this License is provided on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- See the License for the specific provisions governing your rights and
- obligations concerning the Software.
-
- The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-
- Copyright © 2002 by Sun Microsystems, Inc.
-
- All Rights Reserved.
-
- Contributor(s): _______________________________________
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="http://openoffice.org/2000/office"
- xmlns:style="http://openoffice.org/2000/style"
- xmlns:text="http://openoffice.org/2000/text"
- xmlns:table="http://openoffice.org/2000/table"
- xmlns:draw="http://openoffice.org/2000/drawing"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:number="http://openoffice.org/2000/datastyle"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:chart="http://openoffice.org/2000/chart"
- xmlns:dr3d="http://openoffice.org/2000/dr3d"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="http://openoffice.org/2000/form"
- xmlns:script="http://openoffice.org/2000/script"
- office:class="text"
- office:version="1.0"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:meta="http://openoffice.org/2000/meta"
- xmlns:config="http://openoffice.org/2001/config"
- xmlns:help="http://openoffice.org/2000/help"
- xmlns:xt="http://www.jclark.com/xt"
- xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
- xmlns:urlencoder="http://www.jclark.com/xt/java/java.net.URLEncoder"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:java="http://xml.apache.org/xslt/java"
- exclude-result-prefixes="java">
-
- <xsl:output method ="xml"
- encoding ="UTF-8"
- indent ="yes"/>
-
-
-
- <!--+++++ INCLUDED XSL MODULES +++++-->
- <!-- inherited style properties will be collected and written in a CSS header (CSS) -->
- <xsl:include href="style_header.xsl"/>
-
- <!-- inherited style properties will be collected and written as html properties in a temporary variable (HTML4, PALM) -->
- <xsl:include href="style_inlined.xsl"/>
-
- <!-- our xml style properties will be mapped to CSS and HTML4.x properties -->
- <xsl:include href="style_mapping.xsl"/>
-
- <!-- common element handling -->
- <xsl:include href="common.xsl"/>
-
- <!-- table handling -->
- <xsl:include href="table.xsl"/>
-
- <!-- palm handling -->
- <xsl:include href="palm.xsl"/>
-
- <!-- global document handling -->
- <xsl:include href="global_document.xsl"/>
-
-
-
-
-
-
-
- <!--+++++ PARAMETER FROM THE APPLICATION AND GLOBAL VARIABLES +++++-->
-
- <!-- MANDATORY: URL of meta stream -->
- <xsl:param name="metaFileURL"/>
-
- <!-- MANDATORY: URL of styles stream -->
- <xsl:param name="stylesFileURL"/>
-
- <!-- MANDATORY: for resolving relative links
- For resolving realtive links to the packed SO document, i.e. the path/URL of the jared sxw file (e.g. meta.xml, styles.xml, links to graphics in a relative directory) -->
- <xsl:param name="absoluteSourceDirRef"/>
-
- <!-- OPTIONAL (mandatory, when when source is compressed): Necessary for the in the packed OO document embedded files (mostly graphics from the compressed /Picture dir).
- When the OpenOffice (OO) file has been unpacked the absoluteSoureDirRef can be taken,
- Otherwise, a JAR URL could be choosen or when working with OpenOffice a so called Package-URL encoded over HTTP can be used to
- access the jared contents of the the jared document. . -->
- <xsl:param name="jaredRootURL" select="$absoluteSourceDirRef"/>
-
- <!-- OPTIONAL (mandatory, when used in session based environment)
- Useful for WebApplications: if a HTTP session is not cookie based, URL rewriting is beeing used (the session is appended to the URL).
- This URL session is used when creating links to graphics by XSLT. Otherwise the user havt to log again in for every graphic he would like to see. -->
- <xsl:param name="optionalURLSuffix"/>
-
- <!-- OPTIONAL: DPI (dots per inch) the standard solution of given pictures (necessary for the conversion of 'cm' into 'pixel')-->
- <!-- Although many pictures have the 96 dpi resolution, a higher resoltion give better results for common browsers -->
- <xsl:param name="dpi" select="96"/>
-
- <!-- OPTIONAL: in case of using a different processor than a JAVA XSLT, you can unable the Java functionality
- (i.e. debugging time and encoding chapter names for the content-table as href and anchors ) -->
- <xsl:param name="disableJava" select="false"/>
- <xsl:param name="isJavaDisabled" select="boolean($disableJava)"/>
-
- <!-- OPTIONAL: user-agent will be differntiated by this parameter given by application (e.g. java servlet)-->
- <xsl:param name="outputType" select="'CSS_HEADER'"/>
- <!-- set of possible deviceTyps (WML is set in its own startfile main_wml.xsl):
- <xsl:param name="outputType" select="'CSS_HEADER'"/>
- <xsl:param name="outputType" select="'CSS_INLINED'"/>
- <xsl:param name="outputType" select="'PALM'"/> -->
-
- <!-- OPTIONAL: for activating the debug mode set the variable here to 'true()' or give any value from outside -->
- <xsl:param name="debug" select="false"/>
- <xsl:param name="isDebugMode" select="boolean($debug)"/>
-
-<!-- *************************************************************************
- OPTIONAL: NEEDED IN CONNECTION WITH A GLOBAL DOCUMENT -->
-
- <!--SUMMARY:
- following parameter triggers a (quite time consuming) enabling of bookmarks in the table-of-content.
- IN DETAIL:
- Currently some links used in the Office XML (e.g. in the content table as '#7.Some%20Example%20Headline%7Outline')
- is not a valid URL (cmp. bug id# 102311). No file destination is specified nor exist any anchor element for these
- links in the Office XML.
- A workaround for this transformation therefore had to be made. This time-consuming mechanism is disabled by default and
- can be activated by a parameter (i.e. 'disableLinkedTableOfContent'). A creation of an anchor is made for each header element.
- All header titles gonna be encoding to be usable in a relative URL. -->
- <xsl:param name="disableLinkedTableOfContent" select="false()"/>
-
- <!-- The chapter numbers of the current document (as a sequence of a global document) is dependent of the number
- of chapter of the same level in preceding documents. -->
- <xsl:param name="precedingChapterLevel1" select="0"/>
- <xsl:param name="precedingChapterLevel2" select="0"/>
- <xsl:param name="precedingChapterLevel3" select="0"/>
- <xsl:param name="precedingChapterLevel4" select="0"/>
- <xsl:param name="precedingChapterLevel5" select="0"/>
- <xsl:param name="precedingChapterLevel6" select="0"/>
- <xsl:param name="precedingChapterLevel7" select="0"/>
- <xsl:param name="precedingChapterLevel8" select="0"/>
- <xsl:param name="precedingChapterLevel9" select="0"/>
- <xsl:param name="precedingChapterLevel10" select="0"/>
-
- <!-- XML documents containing a table of contents,
- gonna link for usability reason above each chapter to the preceding and following document and the content table -->
- <xsl:param name="contentTableURL"/>
-
- <!-- Needed for the bug workaround of missing content table links
- by this ambigous HTML references from the content table can be evoided-->
- <xsl:param name="globalDocumentRefToCurrentFile"/>
-
- <!-- Needed for the bug workaround of missing content table links
- by this node-set the relation between content-table link and children document header can be unambigous established -->
- <xsl:param name="contentTableHeadings"/>
-
-
-<!-- END OF GLOBAL DOCUMENT SECTION
-*************************************************************************-->
-
-
-
- <!-- works for normal separated zipped xml files as for flat filter single xml file format as well -->
- <xsl:variable name="office:meta-file" select="document($metaFileURL)"/>
- <xsl:variable name="office:styles-file" select="document($stylesFileURL)"/>
- <xsl:variable name="office:font-decls" select="$office:styles-file/*/office:font-decls"/>
- <xsl:variable name="office:styles" select="$office:styles-file/*/office:styles"/>
- <!-- office:automatic-styles may occure in two different files (i.d. content.xml and styles.xml). Furthermore the top level tag is different in a flat xml file -->
- <xsl:variable name="office:automatic-styles" select="/*/office:automatic-styles"/>
-
- <!-- simple declaration of WML used to avoid parser errors -->
- <xsl:variable name="wap-paragraph-elements-without-table-row"/>
- <xsl:variable name="wap-paragraph-elements"/>
- <xsl:template name="wml-repeat-write-row"/>
-
-
- <!-- ************************************* -->
- <!-- *** build the propriate HTML file *** -->
- <!-- ************************************* -->
-
- <xsl:template match="/">
-
- <!--<xsl:message>
-
-
- Entered the styleSheets, transformation begins... </xsl:message>-->
-
- <xsl:choose>
- <xsl:when test="$isDebugMode">
- <xsl:call-template name="check-parameter"/>
-
- <xsl:if test="not($isJavaDisabled)">
- <xsl:call-template name="debug-style-collecting-time"/>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <!-- to access the variable like a node-set it is necessary to convert it
- from a result-tree-fragment (RTF) to a node set using the James Clark extension -->
- <xsl:variable name="collectedGlobalData-RTF">
- <xsl:call-template name='create-all-inline-styles'/>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="function-available('xt:node-set')">
- <xsl:call-template name="start">
- <xsl:with-param name="collectedGlobalData" select="xt:node-set($collectedGlobalData-RTF)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="function-available('xalan:nodeset')">
- <xsl:call-template name="start">
- <xsl:with-param name="collectedGlobalData" select="xalan:nodeset($collectedGlobalData-RTF)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="NodeSetFunctionNotAvailable"/>
- <xsl:call-template name="start"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="start">
- <xsl:param name="collectedGlobalData"/>
-
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER'">
- <xsl:element name="html">
- <xsl:element name="head">
- <xsl:if test="$isDebugMode"><xsl:message>CSS helper variable will be created....</xsl:message></xsl:if>
- <xsl:call-template name='common-header-properties'/>
- <xsl:if test="$isDebugMode"><xsl:message>CSS variable ready, header will be created....</xsl:message></xsl:if>
- <!-- constructing the css header simulating inheritance of style-families by style order -->
- <xsl:call-template name='create-css-styleheader'/>
- <xsl:if test="$isDebugMode"><xsl:message>CSS header creation finished!</xsl:message></xsl:if>
- </xsl:element>
-
-
-
- <xsl:variable name="backgroundImageURL" select="$office:automatic-styles/style:page-master/style:properties/style:background-image/@xlink:href"/>
- <xsl:element name="body">
- <!-- background image -->
- <xsl:if test="$backgroundImageURL">
- <xsl:attribute name="background">
- <xsl:choose>
- <!-- for images jared in open office document -->
- <xsl:when test="contains($backgroundImageURL, '#Pictures/')">
- <!-- creating an absolute http URL to the contained/packed image file -->
- <xsl:value-of select="concat($jaredRootURL, '/Pictures/', substring-after($backgroundImageURL, '#Pictures/'), $optionalURLSuffix)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="src"><xsl:value-of select="$backgroundImageURL"/></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
-
- <!-- processing the content of the xml file -->
- <xsl:apply-templates select="/*/office:body">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:element>
-
- </xsl:element>
- </xsl:when>
-
- <!--+++++ HTML 4.0 INLINING +++++-->
- <xsl:when test="$outputType = 'CSS_INLINED'">
- <xsl:element name="html">
- <xsl:element name="head">
- <xsl:call-template name='common-header-properties'/>
- </xsl:element>
-
- <xsl:variable name="backgroundImageURL" select="$office:automatic-styles/style:page-master/style:properties/style:background-image/@xlink:href"/>
- <xsl:element name="body">
- <!-- background image -->
- <xsl:if test="$backgroundImageURL">
- <xsl:attribute name="background">
- <xsl:choose>
- <!-- for images jared in open office document -->
- <xsl:when test="contains($backgroundImageURL, '#Pictures/')">
- <!-- creating an absolute http URL to the contained/packed image file -->
- <xsl:value-of select="concat($jaredRootURL, '/Pictures/', substring-after($backgroundImageURL, '#Pictures/'), $optionalURLSuffix)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="src"><xsl:value-of select="$backgroundImageURL"/></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- <xsl:apply-templates select="/*/office:body">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:element>
- </xsl:when>
-
- <!--+++++ PALM-VII (3.2 HTML SUBSET) +++++-->
- <xsl:when test="$outputType = 'PALM'">
- <!-- the proxy will convert the html file later to PQA -->
- <xsl:element name="html">
- <xsl:element name="head">
- <xsl:call-template name='palm-header-properties'/>
- </xsl:element>
-
- <xsl:element name="body">
- <!-- processing the content of the xml file -->
- <xsl:apply-templates select="/*/office:body">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:element>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
-
-
- <!-- ********************************************* -->
- <!-- *** Header for CSS_INLINED and CSS_HEADER *** -->
- <!-- ********************************************* -->
-
- <xsl:template name='common-header-properties'>
- <xsl:apply-templates select="$office:meta-file/*/office:meta/dc:title"/>
- <xsl:apply-templates select="$office:meta-file/*/office:meta/dc:description"/>
-<!--2DO add further header elements..
- <xsl:apply-templates select="$office:meta-file/*/office:meta/dc:subject"/>
- <xsl:apply-templates select="$office:meta-file/*/office:meta/meta:keywords[postition()=1]"/>-->
- </xsl:template>
-
- <xsl:template match="dc:title">
- <xsl:element name="title">
- <xsl:value-of select="."/>
- </xsl:element>
- </xsl:template>
-
- <xsl:template match="dc:description">
- <xsl:element name="meta">
- <xsl:attribute name="name">
- <xsl:text>description</xsl:text>
- </xsl:attribute>
- <xsl:attribute name="content">
- <xsl:value-of select="."/>
- </xsl:attribute>
- </xsl:element>
- </xsl:template>
-
-
- <!-- ********************************************* -->
- <!-- *** Measuring the time for style creating *** -->
- <!-- ********************************************* -->
-
-
- <xsl:template name="debug-style-collecting-time">
-
- <xsl:variable name="startTime-RTF">
- <xsl:choose>
- <xsl:when test="function-available('system:current-time-millis')">
- <xsl:value-of select="system:current-time-millis()"/>
- </xsl:when>
- <xsl:when test="function-available('java:java.lang.System.currentTimeMillis')">
- <xsl:value-of select="java:java.lang.System.currentTimeMillis()"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
-
-
-
- <xsl:variable name="collectedGlobalData-RTF">
- <xsl:call-template name='create-all-inline-styles'/>
- </xsl:variable>
-
-
- <xsl:choose>
- <xsl:when test="function-available('xt:node-set')">
- <xsl:message>Creating the inline styles....</xsl:message>
- <xsl:variable name="startTime" select="number(xt:node-set($startTime-RTF))"/>
- <xsl:variable name="collectedGlobalData" select="xt:node-set($collectedGlobalData-RTF)"/>
- <xsl:variable name="endTime" select="system:current-time-millis()"/>
-
- <xsl:message>Time for instantiating style variable: <xsl:value-of select="($endTime - $startTime)"/> ms</xsl:message>
- <xsl:call-template name="start">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="function-available('xalan:nodeset')">
- <xsl:message>Creating the inline styles....</xsl:message>
- <xsl:variable name="startTime" select="number(xalan:nodeset($startTime-RTF))"/>
- <xsl:variable name="endTime" select="java:java.lang.System.currentTimeMillis()"/>
- <xsl:variable name="collectedGlobalData" select="xalan:nodeset($collectedGlobalData-RTF)"/>
-
- <xsl:message>Time for instantiating style variable: <xsl:value-of select="($endTime - $startTime)"/> ms</xsl:message>
- <xsl:call-template name="start">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- </xsl:choose>
-
- </xsl:template>
-
- <!-- DEBUG purpose only: checking the parameters of this template-->
- <xsl:template name="check-parameter">
- <xsl:message>Parameter dpi: <xsl:value-of select="$dpi"/></xsl:message>
- <xsl:message>Parameter metaFileURL: <xsl:value-of select="$metaFileURL"/></xsl:message>
- <xsl:message>Parameter stylesFileURL: <xsl:value-of select="$stylesFileURL"/></xsl:message>
- <xsl:message>Parameter absoluteSourceDirRef: <xsl:value-of select="$absoluteSourceDirRef"/></xsl:message>
- <xsl:message>Parameter precedingChapterLevel1 : <xsl:value-of select="$precedingChapterLevel1"/></xsl:message>
- <xsl:message>Parameter precedingChapterLevel2 : <xsl:value-of select="$precedingChapterLevel2"/></xsl:message>
- <xsl:message>Parameter precedingChapterLevel3 : <xsl:value-of select="$precedingChapterLevel3"/></xsl:message>
- <xsl:message>Parameter precedingChapterLevel4 : <xsl:value-of select="$precedingChapterLevel4"/></xsl:message>
- <xsl:message>Parameter precedingChapterLevel5 : <xsl:value-of select="$precedingChapterLevel5"/></xsl:message>
- <xsl:message>Parameter precedingChapterLevel6 : <xsl:value-of select="$precedingChapterLevel6"/></xsl:message>
- <xsl:message>Parameter precedingChapterLevel7 : <xsl:value-of select="$precedingChapterLevel7"/></xsl:message>
- <xsl:message>Parameter precedingChapterLevel8 : <xsl:value-of select="$precedingChapterLevel8"/></xsl:message>
- <xsl:message>Parameter precedingChapterLevel9 : <xsl:value-of select="$precedingChapterLevel9"/></xsl:message>
- <xsl:message>Parameter precedingChapterLevel10: <xsl:value-of select="$precedingChapterLevel10"/></xsl:message>
- </xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-<!--
-
- The Contents of this file are made available subject to the terms of
- either of the following licenses
-
- - GNU Lesser General Public License Version 2.1
- - Sun Industry Standards Source License Version 1.1
-
- Sun Microsystems Inc., October, 2000
-
- GNU Lesser General Public License Version 2.1
- =============================================
- Copyright 2000 by Sun Microsystems, Inc.
- 901 San Antonio Road, Palo Alto, CA 94303, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License version 2.1, as published by the Free Software Foundation.
-
- 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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
-
-
- Sun Industry Standards Source License Version 1.1
- =================================================
- The contents of this file are subject to the Sun Industry Standards
- Source License Version 1.1 (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.openoffice.org/license.html.
-
- Software provided under this License is provided on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- See the License for the specific provisions governing your rights and
- obligations concerning the Software.
-
- The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-
- Copyright © 2002 by Sun Microsystems, Inc.
-
- All Rights Reserved.
-
- Contributor(s): _______________________________________
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="http://openoffice.org/2000/office"
- xmlns:style="http://openoffice.org/2000/style"
- xmlns:text="http://openoffice.org/2000/text"
- xmlns:table="http://openoffice.org/2000/table"
- xmlns:draw="http://openoffice.org/2000/drawing"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:number="http://openoffice.org/2000/datastyle"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:chart="http://openoffice.org/2000/chart"
- xmlns:dr3d="http://openoffice.org/2000/dr3d"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="http://openoffice.org/2000/form"
- xmlns:script="http://openoffice.org/2000/script"
- office:class="text"
- office:version="1.0"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:meta="http://openoffice.org/2000/meta"
- xmlns:config="http://openoffice.org/2001/config"
- xmlns:help="http://openoffice.org/2000/help"
- xmlns:xt="http://www.jclark.com/xt"
- xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:java="http://xml.apache.org/xslt/java"
- exclude-result-prefixes="java">
-
- <xsl:output cdata-section-elements="meta"/>
-
-
- <!-- **************************** -->
- <!-- *** specific palm header *** -->
- <!-- **************************** -->
-
- <xsl:template name='palm-header-properties'>
- <xsl:element name="meta">
- <xsl:attribute name="name">PalmComputingPlatform</xsl:attribute>
- <xsl:attribute name="content">true</xsl:attribute>
- </xsl:element>
- <xsl:element name="meta">
- <xsl:attribute name="name">HandheldFriendly</xsl:attribute>
- <xsl:attribute name="content">true</xsl:attribute>
- </xsl:element>
- <xsl:element name="meta">
- <xsl:attribute name="name">HistoryListText</xsl:attribute>
- <xsl:attribute name="content">Dateimanager : &date &time</xsl:attribute>
- </xsl:element>
- <xsl:element name="meta">
- <xsl:attribute name="name">description</xsl:attribute>
- <xsl:attribute name="content">StarPortal</xsl:attribute>
- </xsl:element>
- <xsl:element name="meta">
- <xsl:attribute name="name">keywords</xsl:attribute>
- <xsl:attribute name="content">starportal, staroffice, software</xsl:attribute>
- </xsl:element>
- <xsl:element name="meta">
- <xsl:attribute name="http-equiv">Content-Type</xsl:attribute>
- <xsl:attribute name="content">text/html; charset=iso-8859-1</xsl:attribute>
- </xsl:element>
- </xsl:template>
-
-
- <!-- ********************************* -->
- <!-- *** creating table attributes *** -->
- <!-- ********************************* -->
-
- <!-- table data (td) and table header (th) attributes -->
- <xsl:template name="create-attribute-ALIGN">
- <xsl:param name="styleProperties"/>
-
- <xsl:if test="contains($styleProperties, 'align')">
- <xsl:attribute name="align">
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'align:left')">
- <xsl:text>left</xsl:text>
- </xsl:when>
- <xsl:when test="contains($styleProperties, 'align:right')">
- <xsl:text>right</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>center</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:if>
- </xsl:template>
-
-
- <!-- ********************************* -->
- <!-- *** creating List attributes *** -->
- <!-- ********************************* -->
-<!--
- <xsl:template name="create-list-attributes">
- <xsl:param name="styleProperties"/>
-
-
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-2 be implemented
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-
- </xsl:template>
--->
-
- <!-- ************************************************ -->
- <!-- *** creating nested format tags (PALM & WML) *** -->
- <!-- ************************************************ -->
-
- <!-- Italic -->
- <xsl:template name="create-nested-format-tags">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="styleProperties"/>
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'italic')">
- <xsl:element name="i">
- <xsl:call-template name="bold">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="bold">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- Bold -->
- <xsl:template name="bold">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="styleProperties"/>
-
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'bold')">
- <xsl:element name="b">
- <xsl:call-template name="underline">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="underline">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- Underline : last format attribute, which is also used from WML - WML ends here! -->
- <xsl:template name="underline">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="styleProperties"/>
-
- <xsl:choose>
- <xsl:when test="$outputType = 'PALM'">
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'underline')">
- <xsl:element name="u">
- <xsl:call-template name="strikethrough">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="strikethrough">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'underline')">
- <xsl:element name="u">
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- strikethrough -->
- <xsl:template name="strikethrough">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="styleProperties"/>
-
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'strike')">
- <xsl:element name="strike">
- <xsl:call-template name="align">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="align">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- Alignment -->
- <xsl:template name="align">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="styleProperties"/>
-
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'align')">
- <xsl:element name="div">
- <xsl:attribute name="align">
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'align:left')">
- <xsl:text>left</xsl:text>
- </xsl:when>
- <xsl:when test="contains($styleProperties, 'align:right')">
- <xsl:text>right</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>center</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:call-template name="font_combined">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="font_combined">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- Both size and Color for font -->
- <xsl:template name="font_combined">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="styleProperties"/>
-
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'color') and contains($styleProperties, 'size')">
- <xsl:element name="font">
-
- <xsl:attribute name="color">
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'color:#000000')">
- <xsl:text>#000000</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>#FFFFFF</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <xsl:attribute name="size">
- <xsl:value-of select="substring-after(substring-before($styleProperties ,':size'), 'size:')"/>
- </xsl:attribute>
-
- <!-- get the embedded content -->
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="font_simple">
- <xsl:with-param name="styleProperties" select="$styleProperties"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- size or Color for font -->
- <xsl:template name="font_simple">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="styleProperties"/>
-
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'color')">
- <xsl:element name="font">
- <xsl:attribute name="color">
- <xsl:choose>
- <xsl:when test="contains($styleProperties, 'color:#000000')">
- <xsl:text>#000000</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>#FFFFFF</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <!-- get the embedded content -->
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
-
- <xsl:when test="contains($styleProperties, 'size')">
- <xsl:element name="font">
- <xsl:attribute name="size">
- <xsl:value-of select="substring-after(substring-before($styleProperties ,':size'), 'size:')"/>
- </xsl:attribute>
-
- <!-- get the embedded content -->
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
-
- <xsl:otherwise>
- <!-- get the embedded content -->
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-</xsl:stylesheet>
+++ /dev/null
-<!--
-
- The Contents of this file are made available subject to the terms of
- either of the following licenses
-
- - GNU Lesser General Public License Version 2.1
- - Sun Industry Standards Source License Version 1.1
-
- Sun Microsystems Inc., October, 2000
-
- GNU Lesser General Public License Version 2.1
- =============================================
- Copyright 2000 by Sun Microsystems, Inc.
- 901 San Antonio Road, Palo Alto, CA 94303, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License version 2.1, as published by the Free Software Foundation.
-
- 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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
-
-
- Sun Industry Standards Source License Version 1.1
- =================================================
- The contents of this file are subject to the Sun Industry Standards
- Source License Version 1.1 (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.openoffice.org/license.html.
-
- Software provided under this License is provided on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- See the License for the specific provisions governing your rights and
- obligations concerning the Software.
-
- The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-
- Copyright © 2002 by Sun Microsystems, Inc.
-
- All Rights Reserved.
-
- Contributor(s): _______________________________________
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="http://openoffice.org/2000/office"
- xmlns:style="http://openoffice.org/2000/style"
- xmlns:text="http://openoffice.org/2000/text"
- xmlns:table="http://openoffice.org/2000/table"
- xmlns:draw="http://openoffice.org/2000/drawing"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:number="http://openoffice.org/2000/datastyle"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:chart="http://openoffice.org/2000/chart"
- xmlns:dr3d="http://openoffice.org/2000/dr3d"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="http://openoffice.org/2000/form"
- xmlns:script="http://openoffice.org/2000/script"
- office:class="text"
- office:version="1.0"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:meta="http://openoffice.org/2000/meta"
- xmlns:config="http://openoffice.org/2001/config"
- xmlns:help="http://openoffice.org/2000/help"
- xmlns:xt="http://www.jclark.com/xt"
- xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:java="http://xml.apache.org/xslt/java"
- exclude-result-prefixes="java">
-
-
-
- <!-- ****************************** -->
- <!-- *** style sheet processing *** -->
- <!-- ****************************** -->
-
-
- <xsl:template name='create-css-styleheader'>
- <xsl:comment>
- <xsl:text>The CSS style header method for setting styles</xsl:text>
- </xsl:comment>
- <xsl:element name="style">
- <xsl:attribute name="type">text/css</xsl:attribute>
- <xsl:comment>
- <xsl:text>
-
- </xsl:text>
- <xsl:call-template name="write-default-styles"/>
-
- <!-- THE STYLE PROPERTIES OF THE FIRST WRITTEN STYLE (PARENT) IS GIVEN OUT -->
-
- <!-- 1) styles from office:styles are possible parent from all (itself or office:automatic-styles).
- Therefore they are created first.
- Beginning with the top-level parents (the styles without any parent). -->
- <xsl:for-each select="$office:styles/style:style[not(@style:parent-style-name)]">
-
- <xsl:call-template name="write-styleproperty-line"/>
- <xsl:call-template name="write-styleproperty-lines-for-children"/>
- </xsl:for-each>
-
- <xsl:text> </xsl:text>
-
- <!-- 2) styles from office:automatic-styles can only be parent of styles from the office:automatic-styles section.
- Beginning with top-level styles, again, all children style will be recursivly traversed -->
- <xsl:for-each select="$office:automatic-styles/style:style[not(@style:parent-style-name)]">
- <xsl:call-template name="write-styleproperty-line">
- <xsl:with-param name="searchOnlyInAutomaticStyles" select="true()"/>
- </xsl:call-template>
- <xsl:call-template name="write-styleproperty-lines-for-children">
- <xsl:with-param name="searchOnlyInAutomaticStyles"/>
- </xsl:call-template>
- </xsl:for-each>
- //</xsl:comment>
- </xsl:element>
- </xsl:template>
-
-
- <xsl:template name='write-styleproperty-line'>
- <xsl:param name="searchOnlyInAutomaticStyles"/>
-
- <xsl:variable name="styleProperties">
- <xsl:call-template name="write-style-properties">
- <xsl:with-param name="styleAttributePath" select="current()/style:properties/@*"/>
- </xsl:call-template>
- </xsl:variable>
-
- <!-- do not write styles with no css property -->
- <xsl:if test="not(string-length($styleProperties) = 0)">
- <!-- write out the name of the current (parent) style in the CSS headersection (e.g. "span.myStyle") -->
- <xsl:call-template name="write-style-name">
- <xsl:with-param name="is-parent-style" select="true()"/>
- </xsl:call-template>
-
- <!-- the names of all styles children will be written out(office:style AND office:automatic-style) -->
- <xsl:call-template name="write-children-style-names">
- <xsl:with-param name="parentStyleName" select="@style:name"/>
- <xsl:with-param name="parentStyleFamily" select="@style:family"/>
- <xsl:with-param name="searchOnlyInAutomaticStyles"/>
- </xsl:call-template>
-
- <!-- the style properties of the first written style (parent) is given out -->
- <xsl:text> {
- </xsl:text>
- <xsl:value-of select="$styleProperties"/>
- <xsl:text>}
- </xsl:text>
-
- </xsl:if>
-
-
-
- </xsl:template>
-
-
-
-
- <!-- RECURSION WITH ENDCONDITON: adding style classes for all existing childs -->
- <xsl:template name='write-styleproperty-lines-for-children'>
- <xsl:param name="searchOnlyInAutomaticStyles"/>
-
- <xsl:variable name="parentStyleName" select="@style:name"/>
- <xsl:variable name="parentStyleFamily" select="@style:family"/>
-
- <xsl:if test="not(searchOnlyInAutomaticStyles)">
- <xsl:for-each select="../style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
- <xsl:call-template name="write-styleproperty-line"/>
- <xsl:call-template name="write-styleproperty-lines-for-children"/>
- </xsl:for-each>
- </xsl:if>
- <xsl:for-each select="$office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
- <xsl:call-template name="write-styleproperty-line">
- <xsl:with-param name="searchOnlyInAutomaticStyles"/>
- </xsl:call-template>
- <xsl:call-template name="write-styleproperty-lines-for-children">
- <xsl:with-param name="searchOnlyInAutomaticStyles"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:template>
-
-
- <xsl:template name="write-default-styles">
-
- <!-- some default attributes in xml have to be explicitly set in HTML (e.g. margin-top="0") -->
- <xsl:text>*.OOo_defaults</xsl:text>
-
- <xsl:for-each select="$office:styles/style:style">
- <xsl:text>, </xsl:text>
- <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
- </xsl:for-each>
-
- <xsl:for-each select="$office:automatic-styles/style:style">
- <xsl:text>, </xsl:text>
- <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
- </xsl:for-each>
- <!-- 2DO: the defaults might be better collected and written in a separated (XML) file -->
-<xsl:text> {
- margin-top:0cm; margin-bottom:0cm; }
- </xsl:text>
-
- <xsl:for-each select="$office:styles/style:default-style">
- <xsl:call-template name="write-default-style"/>
- </xsl:for-each>
-
- <xsl:for-each select="$office:automatic-styles/style:default-style">
- <xsl:call-template name="write-default-style"/>
- </xsl:for-each>
-
- </xsl:template>
-
-
-
- <xsl:template name="write-default-style">
- <xsl:variable name="family-style" select="@style:family"/>
-
- <!-- some default attributes for format families (e.g. graphics, paragraphs, etc.) written as style:default-style -->
- <xsl:value-of select="concat('*.', translate($family-style, '. %()/\', ''), '_defaults')"/>
-
- <xsl:for-each select="$office:styles/style:style[@style:family = $family-style]">
- <xsl:text>, </xsl:text>
- <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
- </xsl:for-each>
-
- <xsl:for-each select="$office:automatic-styles/style:style[@style:family = $family-style]">
- <xsl:text>, </xsl:text>
- <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
- </xsl:for-each>
-
-
- <xsl:variable name="styleProperties">
- <xsl:call-template name="write-style-properties">
- <xsl:with-param name="styleAttributePath" select="current()/style:properties/@*"/>
- </xsl:call-template>
- </xsl:variable>
-
- <!-- do not write styles with no css property -->
- <xsl:if test="not(string-length($styleProperties) = 0)">
- <!-- the style properties of the first written style (parent) is given out -->
- <xsl:text> {
- </xsl:text>
- <xsl:value-of select="$styleProperties"/>
- <xsl:text>}
- </xsl:text>
- </xsl:if>
-
- </xsl:template>
-
-
- <!--++
- The parent style will be written out!
- For each Style:family a prefix must be added
- <!ENTITY % styleFamily
- "(paragraph|text|section|table|table-column|table-row|table-cell|table-page|chart|graphics|default|drawing-page|presentation|control)">
- ++-->
- <xsl:template name="write-style-name">
- <xsl:param name="is-parent-style"/>
-
- <!-- This construct is for list elements. Whenever a paragraph element is being used as child of a list element the name paragraph style is been used for
- the list item. This can be switched as the paragaph style-name and the list-style-name are in the same element.
- Otherwise there would be formatting errors (e.g. margin-left will be used for the content in the list elment and not for the list element itself). -->
- <xsl:variable name="style-name">
- <xsl:choose>
- <xsl:when test="@style:list-style-name">
- <xsl:value-of select="@style:list-style-name"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@style:name"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:if test="not($is-parent-style)">
- <xsl:text>, </xsl:text>
- </xsl:if>
-
- <xsl:choose>
- <!-- normally 'p.' would be used as CSS element,
- but header (h1, h2,...) are also from the style:family paragraph -->
- <xsl:when test="@style:family='paragraph'">
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='text'">
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='section'">
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='table'">
- <xsl:value-of select="concat('table.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='table-column'">
- <!-- as column styles have to be included as span styles AFTER the table (no two class attributes in TD allowed -->
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='table-row'">
- <xsl:value-of select="concat('tr.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='table-cell'">
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='table-page'">
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='chart'">
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='graphics'">
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='default'">
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='drawing-page'">
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='presentation'">
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- <xsl:when test="@style:family='control'">
- <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- finding all style child of a section and give their styleIdentifier to the output -->
- <xsl:template name='write-children-style-names'>
- <xsl:param name="parentStyleName" select="@style:name"/>
- <xsl:param name="parentStyleFamily" select="@style:family"/>
- <xsl:param name="searchOnlyInAutomaticStyles"/>
-
-
- <!--** the names of all office:styles children will be written out
- ** (a automatic style can only have children in the office:automatic-style section) -->
-
- <!-- if NOT called from a office:automatic-style parent -->
- <xsl:if test="not(searchOnlyInAutomaticStyles)">
- <!-- for all children in the office:style section -->
- <xsl:for-each select="../style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
- <!-- write the style name in the css header -->
- <xsl:call-template name="write-style-name"/>
-
- <!-- search for child styles -->
- <xsl:call-template name="write-children-style-names">
- <xsl:with-param name="parentStyleName" select="@style:name"/>
- <xsl:with-param name="parentStyleFamily" select="@style:family"/>
- </xsl:call-template>
-
- </xsl:for-each>
- </xsl:if>
-
- <!--** the names of all office:automatic-styles children will be written out -->
-
- <!-- for all children in the office:automatic-style section -->
- <xsl:for-each select="$office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
- <!-- write the style name in the css header -->
- <xsl:call-template name="write-style-name"/>
-
- <!-- search for child styles -->
- <xsl:call-template name="write-children-style-names">
- <xsl:with-param name="parentStyleName" select="@style:name"/>
- <xsl:with-param name="parentStyleFamily" select="@style:family"/>
- <xsl:with-param name="searchOnlyInAutomaticStyles"/>
- </xsl:call-template>
-
- </xsl:for-each>
- </xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-<!--
-
- The Contents of this file are made available subject to the terms of
- either of the following licenses
-
- - GNU Lesser General Public License Version 2.1
- - Sun Industry Standards Source License Version 1.1
-
- Sun Microsystems Inc., October, 2000
-
- GNU Lesser General Public License Version 2.1
- =============================================
- Copyright 2000 by Sun Microsystems, Inc.
- 901 San Antonio Road, Palo Alto, CA 94303, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License version 2.1, as published by the Free Software Foundation.
-
- 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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
-
-
- Sun Industry Standards Source License Version 1.1
- =================================================
- The contents of this file are subject to the Sun Industry Standards
- Source License Version 1.1 (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.openoffice.org/license.html.
-
- Software provided under this License is provided on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- See the License for the specific provisions governing your rights and
- obligations concerning the Software.
-
- The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-
- Copyright © 2002 by Sun Microsystems, Inc.
-
- All Rights Reserved.
-
- Contributor(s): _______________________________________
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="http://openoffice.org/2000/office"
- xmlns:style="http://openoffice.org/2000/style"
- xmlns:text="http://openoffice.org/2000/text"
- xmlns:table="http://openoffice.org/2000/table"
- xmlns:draw="http://openoffice.org/2000/drawing"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:number="http://openoffice.org/2000/datastyle"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:chart="http://openoffice.org/2000/chart"
- xmlns:dr3d="http://openoffice.org/2000/dr3d"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="http://openoffice.org/2000/form"
- xmlns:script="http://openoffice.org/2000/script"
- office:class="text"
- office:version="1.0"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:meta="http://openoffice.org/2000/meta"
- xmlns:config="http://openoffice.org/2001/config"
- xmlns:help="http://openoffice.org/2000/help"
- xmlns:xt="http://www.jclark.com/xt"
- xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:java="http://xml.apache.org/xslt/java"
- exclude-result-prefixes="java">
-
-
-
- <!-- ********************************************* -->
- <!-- *** hard attributed (inlined) properties *** -->
- <!-- ********************************************* -->
-
-
- <!-- RESTRICTIONS:
- 1) As the styles-node-variables are NOT global, the style variables are not global, either!!
- 2) As a list of elements can only be added to a variable as a result tree fragment the
- extension is neccessary!!
- -->
-
- <!-- 2DO: Inline styles do not inherit from XML office defaults nor font:family defaults as the style header does
- (cp. stylesheet 'style_header.xsl' and the 'write-default-styles' template) -->
-
- <xsl:template name='create-all-inline-styles'>
-
- <!--** traversee all style trees and their branches collecting style properties **-->
- <xsl:element name="allstyles">
- <!--** traversee all office:styles trees beginning with the top-level styles**-->
- <xsl:for-each select="$office:styles/style:style[not(@style:parent-style-name)]">
-
- <!--** give out the style properties of the parent node **-->
- <xsl:call-template name='write-current-and-inherited-style-properties'>
- <xsl:with-param name="styles-node" select="$office:styles"/>
- <xsl:with-param name="style-family" select="@style:family"/>
- <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
- </xsl:call-template>
-
- <!--** all office:styles children of the current top-level office:styles **-->
- <xsl:call-template name='for-all-templates-child-styles'>
- <xsl:with-param name="parentStyleName" select="@style:name"/>
- <xsl:with-param name="parentStyleFamily" select="@style:family"/>
- <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
- </xsl:call-template>
-
- <!--** all office:automatic-styles children of the current top-level style **-->
- <xsl:call-template name='for-all-automatic-child-styles'>
- <xsl:with-param name="parentStyleName" select="@style:name"/>
- <xsl:with-param name="parentStyleFamily" select="@style:family"/>
- <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
- </xsl:call-template>
- </xsl:for-each>
-
- <!--** traversee all office:automatic-styles trees beginning with the top-level styles **-->
- <xsl:for-each select="$office:automatic-styles/style:style[not(@style:parent-style-name)]">
- <!--** give out the style properties of the parent node **-->
- <xsl:call-template name='write-current-and-inherited-style-properties'>
- <xsl:with-param name="styles-node" select="$office:automatic-styles"/>
- <xsl:with-param name="style-family" select="@style:family"/>
- <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
- </xsl:call-template>
-
- <!--** all children of the top-level office:automatic-styless **-->
- <xsl:call-template name='for-all-automatic-child-styles'>
- <xsl:with-param name="parentStyleName" select="@style:name"/>
- <xsl:with-param name="parentStyleFamily" select="@style:family"/>
- <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
-
-
-
- <xsl:template name='for-all-templates-child-styles'>
- <xsl:param name="parentStyleName"/>
- <xsl:param name="parentStyleFamily"/>
- <xsl:param name="style-name-tokenized"/>
-
- <xsl:for-each select="../style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
- <!--** give out the style properties of the current node **-->
- <xsl:element name="{$style-name-tokenized}">
- <xsl:call-template name='write-current-and-inherited-style-properties'>
- <xsl:with-param name="styles-node" select="$office:styles"/>
- <xsl:with-param name="style-family" select="@style:family"/>
- <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
- </xsl:call-template>
- </xsl:element>
-
- <!--** for all template-children of the current office:styles **-->
- <xsl:call-template name='for-all-templates-child-styles'>
- <xsl:with-param name="styles-node" select="$office:styles"/>
- <xsl:with-param name="parentStyleName" select="@style:name"/>
- <xsl:with-param name="parentStyleFamily" select="@style:family"/>
- <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
- </xsl:call-template>
-
- <!--** for all automatic-children of the current office:styles **-->
- <xsl:call-template name='for-all-automatic-child-styles'>
- <xsl:with-param name="styles-node" select="$office:automatic-styles"/>
- <xsl:with-param name="parentStyleName" select="@style:name"/>
- <xsl:with-param name="parentStyleFamily" select="@style:family"/>
- <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
- </xsl:call-template>
-
- </xsl:for-each>
- </xsl:template>
-
-
-
- <xsl:template name='for-all-automatic-child-styles'>
- <xsl:param name="styles-node"/>
- <xsl:param name="parentStyleName"/>
- <xsl:param name="parentStyleFamily"/>
- <xsl:param name="style-name-tokenized"/>
-
- <xsl:for-each select="$office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
- <!--** give out the style properties of the current node **-->
- <xsl:element name="{$style-name-tokenized}">
- <xsl:call-template name='write-current-and-inherited-style-properties'>
- <xsl:with-param name="styles-node" select="$office:automatic-styles"/>
- <xsl:with-param name="style-family" select="@style:family"/>
- <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
- </xsl:call-template>
- </xsl:element>
-
- <!--** for all automatic-children of the current office:automatic-styles **-->
- <xsl:call-template name='for-all-automatic-child-styles'>
- <xsl:with-param name="styles-node" select="$office:automatic-styles"/>
- <xsl:with-param name="parentStyleName" select="@style:name"/>
- <xsl:with-param name="parentStyleFamily" select="@style:family"/>
- <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:template>
-
-
- <xsl:template name='write-current-and-inherited-style-properties'>
- <xsl:param name="style-family"/>
- <xsl:param name="styles-node"/>
- <xsl:param name="style-name-tokenized"/>
-
- <xsl:element name="{$style-name-tokenized}">
- <xsl:variable name="current-style-name" select="@style:name"/>
- <xsl:variable name="parent-style-name" select="@style:parent-style-name"/>
-
- <xsl:variable name="new-property-list">
- <!--*** COLLECT STYLE ATTRIBUTES (only toplevel) ***-->
- <xsl:call-template name="write-style-properties">
- <xsl:with-param name="styleAttributePath" select="$styles-node/style:style[@style:family=$style-family and @style:name=$current-style-name]/style:properties/@*"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:choose>
- <!--*** @End: GIVE OUT All COLLECTED STYLE ATTRIBUTES (only toplevel) ***-->
- <xsl:when test="string-length($parent-style-name)=0">
- <!--** if no styleParent is given, the properties are given out at once **-->
- <xsl:value-of select="normalize-space($new-property-list)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="new-property-names">
- <xsl:for-each select="$styles-node/style:style[@style:family=$style-family and @style:name=$current-style-name]/style:properties/@*">
- <xsl:value-of select="name()"/>
- </xsl:for-each>
- </xsl:variable>
- <!--** further attributes of the parent style must be collected **-->
- <xsl:call-template name="add-parent-style-attributes">
- <xsl:with-param name="property-name-list" select="$new-property-names"/>
- <xsl:with-param name="complete-property-list" select="normalize-space($new-property-list)"/>
- <xsl:with-param name="current-style-name" select="$current-style-name"/>
- <xsl:with-param name="parent-style-name" select="$parent-style-name"/>
- <xsl:with-param name="style-family" select="$style-family"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:template>
-
-
-
- <xsl:template name="add-parent-style-attributes">
- <xsl:param name="property-name-list"/>
- <xsl:param name="complete-property-list"/>
- <xsl:param name="current-style-name"/>
- <xsl:param name="parent-style-name"/>
- <xsl:param name="style-family"/>
-
- <!--*** New two be added property names will be collected (only one variable per template) ***-->
- <xsl:variable name="new-property-names">
- <xsl:call-template name="get-new-style-names">
- <xsl:with-param name="property-name-list" select="$property-name-list"/>
- <xsl:with-param name="parent-style-name" select="$parent-style-name"/>
- <xsl:with-param name="current-style-name" select="$current-style-name"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:choose>
- <!--*** check if the new parent style exist in the office:automatic-styles section (defined by name and family) ***-->
- <xsl:when test="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$current-style-name]">
- <!--*** RECURSION: adding new parent style attributes to the current style ***-->
- <xsl:variable name="new-property-attributes">
- <xsl:call-template name="get-new-style-attributes">
- <xsl:with-param name="new-property-names" select="$new-property-names"/>
- <xsl:with-param name="current-style-name" select="$current-style-name"/>
- <xsl:with-param name="parent-style-name" select="$parent-style-name"/>
- </xsl:call-template>
- </xsl:variable>
- <!--*** End CONDITION: the last style parent has already been executed ***-->
- <xsl:variable name="new-parent-style-name" select="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/@style:parent-style-name"/>
- <xsl:choose>
- <xsl:when test="string-length($new-parent-style-name)=0">
- <!--** no further parent is found, the given parameter property-node is the final style -->
- <xsl:value-of select="concat($complete-property-list,$new-property-attributes)"/>
- </xsl:when>
- <xsl:otherwise>
- <!--** further attributes of the parent style must be collected **-->
- <xsl:call-template name="add-parent-style-attributes">
- <xsl:with-param name="property-name-list" select="concat($property-name-list, $new-property-names)"/>
- <xsl:with-param name="complete-property-list" select="concat($complete-property-list,$new-property-attributes)"/>
- <xsl:with-param name="current-style-name" select="$parent-style-name"/>
- <xsl:with-param name="parent-style-name" select="$new-parent-style-name"/>
- <xsl:with-param name="style-family" select="$style-family"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
-
- <!--** the specific style (defined by name and family) must be found in the office:styles section -->
- <xsl:otherwise>
- <!--*** RECURSION: adding new parent style attributes to the current style ***-->
- <!--*** adding new parent style attributes to the current style ***-->
- <xsl:variable name="new-property-attributes">
- <xsl:call-template name="get-new-style-attributes">
- <xsl:with-param name="new-property-names" select="$new-property-names"/>
- <xsl:with-param name="current-style-name" select="$current-style-name"/>
- <xsl:with-param name="parent-style-name" select="$parent-style-name"/>
- </xsl:call-template>
- </xsl:variable>
- <!--*** End CONDITION: the last style parent has already been executed ***-->
- <xsl:variable name="new-parent-style-name" select="$office:styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/@style:parent-style-name"/>
- <xsl:choose>
- <xsl:when test="string-length($new-parent-style-name)=0">
- <!--** no further parent is found, the given parameter property-node is the final style -->
- <xsl:value-of select="concat($complete-property-list,$new-property-attributes)"/>
- </xsl:when>
- <xsl:otherwise>
- <!--** further attributes of the parent style must be collected ** -->
- <xsl:call-template name="add-parent-style-attributes">
- <xsl:with-param name="property-name-list" select="concat($property-name-list, $new-property-names)"/>
- <xsl:with-param name="complete-property-list" select="concat($complete-property-list,$new-property-attributes)"/>
- <xsl:with-param name="current-style-name" select="$parent-style-name"/>
- <xsl:with-param name="parent-style-name" select="$new-parent-style-name"/>
- <xsl:with-param name="style-family" select="$style-family"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <xsl:template name="get-new-style-names">
- <xsl:param name="property-name-list"/>
- <xsl:param name="parent-style-name"/>
- <xsl:param name="current-style-name"/>
- <!--** where to find the specific style (defined by name and family) wheter in office:automatic-styles or office:styles section -->
- <xsl:choose>
- <!--** if the specific style (defined by name and family) can be found in the office:automatic-styles section -->
- <xsl:when test="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]">
- <xsl:variable name="parent-property-node" select="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>
-
- <xsl:variable name="new-property-name-list">
- <xsl:for-each select="$parent-property-node/@*[not(contains($property-name-list, name()))]">
- <xsl:value-of select="name()"/>
- </xsl:for-each>
- </xsl:variable>
- <xsl:value-of select="$new-property-name-list"/>
- </xsl:when>
- <!--** the specific style (defined by name and family) should be found in the office:styles section -->
- <xsl:otherwise>
- <xsl:variable name="parent-property-node" select="$office:styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>
- <xsl:variable name="new-property-name-list">
- <xsl:for-each select="$parent-property-node/@*[not(contains($property-name-list, name()))]">
- <xsl:value-of select="name()"/>
- </xsl:for-each>
- </xsl:variable>
- <xsl:value-of select="$new-property-name-list"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <xsl:template name="get-new-style-attributes">
- <xsl:param name="new-property-names"/>
- <xsl:param name="current-style-name"/>
- <xsl:param name="parent-style-name"/>
-
- <!--** where to find the specific style (defined by name and family) whether in office:automatic-styles or office:styles section -->
- <xsl:choose>
- <!--** if the specific style (defined by name and family) can be found in the office:automatic-styles section -->
- <xsl:when test="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]">
- <xsl:variable name="parent-property-node" select="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>
- <xsl:variable name="new-property-name-list">
- <xsl:call-template name="write-style-properties">
- <xsl:with-param name="styleAttributePath" select="$parent-property-node/@*[contains($new-property-names, name())]"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:value-of select="normalize-space($new-property-name-list)"/>
- </xsl:when>
- <!--** otherwise the specific style (defined by name and family) should be found in the office:styles section -->
- <xsl:otherwise>
- <xsl:variable name="parent-property-node" select="$office:styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>
- <xsl:variable name="new-property-name-list">
- <xsl:call-template name="write-style-properties">
- <xsl:with-param name="styleAttributePath" select="$parent-property-node/@*[contains($new-property-names, name())]"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:value-of select="normalize-space($new-property-name-list)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-</xsl:stylesheet>
+++ /dev/null
-<!--
-
- The Contents of this file are made available subject to the terms of
- either of the following licenses
-
- - GNU Lesser General Public License Version 2.1
- - Sun Industry Standards Source License Version 1.1
-
- Sun Microsystems Inc., October, 2000
-
- GNU Lesser General Public License Version 2.1
- =============================================
- Copyright 2000 by Sun Microsystems, Inc.
- 901 San Antonio Road, Palo Alto, CA 94303, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License version 2.1, as published by the Free Software Foundation.
-
- 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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
-
-
- Sun Industry Standards Source License Version 1.1
- =================================================
- The contents of this file are subject to the Sun Industry Standards
- Source License Version 1.1 (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.openoffice.org/license.html.
-
- Software provided under this License is provided on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- See the License for the specific provisions governing your rights and
- obligations concerning the Software.
-
- The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-
- Copyright © 2002 by Sun Microsystems, Inc.
-
- All Rights Reserved.
-
- Contributor(s): _______________________________________
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="http://openoffice.org/2000/office"
- xmlns:style="http://openoffice.org/2000/style"
- xmlns:text="http://openoffice.org/2000/text"
- xmlns:table="http://openoffice.org/2000/table"
- xmlns:draw="http://openoffice.org/2000/drawing"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:number="http://openoffice.org/2000/datastyle"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:chart="http://openoffice.org/2000/chart"
- xmlns:dr3d="http://openoffice.org/2000/dr3d"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="http://openoffice.org/2000/form"
- xmlns:script="http://openoffice.org/2000/script"
- office:class="text"
- office:version="1.0"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:meta="http://openoffice.org/2000/meta"
- xmlns:config="http://openoffice.org/2001/config"
- xmlns:help="http://openoffice.org/2000/help"
- xmlns:xt="http://www.jclark.com/xt"
- xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:java="http://xml.apache.org/xslt/java"
- exclude-result-prefixes="java">
-
-
- <xsl:template name="write-style-properties">
- <xsl:param name="styleAttributePath"/>
-
- <xsl:choose>
- <!--+++++ CSS PROPERTIES +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER' or $outputType = 'CSS_INLINED'">
-
- <xsl:for-each select="$styleAttributePath">
- <!-- isDebugModeMESSAGE:
- <xsl:message> Name:<xsl:value-of select="name()"/> Value:<xsl:value-of select="."/></xsl:message> -->
-
-
- <!-- <!ATTLIST style:properties style:horizontal-pos (from-left|left|center|right|from-inside|inside|outside)#IMPLIED>-->
- <!-- 2DO: is inside/from-inside also better showable ? -->
- <!-- !!!! 2DO: Still there have to be placed a <br clear='all'/> to disable the flow!!!!-->
- <!-- The OOo attribute 'style:number-wrapped-paragraphs' is currently ignored -->
- <xsl:choose>
- <xsl:when test='name(.)="style:wrap"'>
- <xsl:choose>
- <xsl:when test='.="left"'>
- <xsl:text>float: right; </xsl:text>
- </xsl:when>
- <xsl:when test='.="right"'>
- <xsl:text>float: left; </xsl:text>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
-
- <xsl:when test='name(.) = "style:horizontal-pos"'>
- <xsl:choose>
- <xsl:when test='.="left"'>
- <xsl:text>align: left; </xsl:text>
- </xsl:when>
- <xsl:when test='.="right"'>
- <xsl:text>align: right; </xsl:text>
- </xsl:when>
- <xsl:when test='.="center"'>
- <xsl:text>align: center; </xsl:text>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
-<!-- results into a bad view (overlapped) in Mozilla 1.0
- <xsl:when test='name(.) = "table:align"'>
- <xsl:choose>
- <xsl:when test='.="left"'>
- <xsl:text>float: right; </xsl:text>
- </xsl:when>
- <xsl:when test='.="right"'>
- <xsl:text>float: left; </xsl:text>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
--->
-
- <!-- PADDING for all variations: fo:padding, fo:padding-top, fo:padding-bottom, fo:padding-left, fo:padding-right -->
- <xsl:when test='contains(name(.),"fo:padding")'>
- <xsl:text>padding: </xsl:text>
- <xsl:value-of select="."/>
- <xsl:text>; </xsl:text>
- </xsl:when>
- <!--
- fo:border
- fo:border-top
- fo:border-bottom
- fo:border-left
- fo:border-right
-
- At present, all four borders must be set simultaneously by using either
- the fo:border property or by attaching all four of the other border
- properties to an item set element. In the latter case, if one or more
- of the properties is missing their values are assumed to be none. The
- only border styles supported are none or hidden, solid, and double. Any
- other border style specified is displayed as solid. Transparent borders
- are not supported and the border widths thin, medium, and thick are
- mapped to lengths. In addition, only some distinct border widths are
- supported. Unsupported widths are rounded up to the next supported
- width.
- If there are no padding properties specified within the same
- item set element, a default padding is used for sides that have a
- border. A value of 0cm is used for sides without a border.
- (cp. wd-so-xml-text.sdw)
- -->
-
-<!--2DO START: change measurement equally -->
- <xsl:when test='name(.)="fo:border"'>
- <xsl:choose>
- <!-- changing the distance measure: inch to in -->
- <xsl:when test="contains(., 'ch')">
- <xsl:text>border-width:</xsl:text><xsl:value-of select="substring-before(.,'ch ')"/><xsl:text>; </xsl:text>
- <xsl:text>border-style:</xsl:text><xsl:value-of select="substring-before(substring-after(.,'ch '), ' ')"/><xsl:text>; </xsl:text>
- <xsl:text>border-color:</xsl:text><xsl:value-of select="substring-after(substring-after(.,'ch '), ' ')"/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test="contains(., 'cm')">
- <xsl:text>border-width:</xsl:text><xsl:value-of select="substring-before(.,' ')"/><xsl:text>; </xsl:text>
- <xsl:text>border-style:</xsl:text><xsl:value-of select="substring-before(substring-after(.,'cm '), ' ')"/><xsl:text>; </xsl:text>
- <xsl:text>border-color:</xsl:text><xsl:value-of select="substring-after(substring-after(.,'cm '), ' ')"/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test="contains(., 'pt')">
- <xsl:text>border-width:</xsl:text><xsl:value-of select="substring-before(.,' ')"/><xsl:text>; </xsl:text>
- <xsl:text>border-style:</xsl:text><xsl:value-of select="substring-before(substring-after(.,'pt '), ' ')"/><xsl:text>; </xsl:text>
- <xsl:text>border-color:</xsl:text><xsl:value-of select="substring-after(substring-after(.,'pt '), ' ')"/><xsl:text>; </xsl:text>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:when test='name(.)="fo:border-top"'>
- <xsl:text>border-top: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:border-bottom"'>
- <xsl:text>border-bottom: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:border-left"'>
- <xsl:text>border-left: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:border-right"'>
- <xsl:text>border-right: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="style:column-width"'>
- <xsl:choose>
- <!-- changing the distance measure: inch to in -->
- <xsl:when test="contains(., 'ch')">
- <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test='name(.)="style:row-height"'>
- <xsl:choose>
- <!-- changing the distance measure: inch to in -->
- <xsl:when test="contains(., 'ch')">
- <xsl:text>height:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>height:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test='name(.)="fo:width"'>
- <xsl:choose>
- <!-- changing the distance measure: inch to in -->
- <xsl:when test="contains(., 'ch')">
- <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
-<!--2DO END: change measurement equally -->
- <xsl:when test='name(.)="fo:font-style"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="style:font-name"'>
- <xsl:text>font-family:</xsl:text>
- <xsl:variable name="content" select="."/>
- <xsl:value-of select="$office:font-decls/style:font-decl[@style:name=$content]/@fo:font-family"/>
- <xsl:text>; </xsl:text>
- <xsl:if test="contains($office:font-decls/style:font-decl[@style:name=$content]/@style:font-style-name, 'Italic')">
- <xsl:text>font-style:italic; </xsl:text>
- </xsl:if>
- <xsl:if test="contains($office:font-decls/style:font-decl[@style:name=$content]/@style:font-style-name, 'Bold')">
- <xsl:text>font-weight:bold; </xsl:text>
- </xsl:if>
- </xsl:when>
- <xsl:when test='name(.)="fo:font-weight"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:font-size"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:font-family"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:color"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:margin-left"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:margin-right"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:margin-top"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:margin-bottom"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:line-height"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:text-align"'>
- <!-- IMPORTANT is necessary as table cell value alignment is decided by runtime over the valuetype
- Otherwise a table cell style-class will ALWAYS be overwritten by the run-time value -->
- <xsl:choose>
- <xsl:when test="contains(., 'start')">
- <xsl:text>text-align:left ! important; </xsl:text>
- </xsl:when>
- <xsl:when test="contains(., 'end')">
- <xsl:text>text-align:right ! important; </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>text-align:</xsl:text><xsl:value-of select='.'/><xsl:text> ! important; </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test='name(.)="fo:text-indent"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="style:text-background-color"'>
- <xsl:text>background-color:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="fo:background-color"'>
- <xsl:text>background-color:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="style:background-image"'>
- <xsl:text>background-image:url(</xsl:text><xsl:value-of select="@xlink:href"/><xsl:text>); </xsl:text>
- <xsl:choose>
- <xsl:when test="@style:repeat = 'repeat'">
- <xsl:text>background-repeat:repeat; </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>background-repeat:no-repeat; </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <!-- text-shadow is a CSS2 feature and yet not common used in user-agents -->
- <xsl:when test='name(.)="fo:text-shadow"'>
- <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="style:text-crossing-out"'>
- <xsl:if test='not(.="none")'>
- <xsl:text>text-decoration:line-through; </xsl:text>
- </xsl:if>
- </xsl:when>
- <xsl:when test='name(.)="style:text-underline"'>
- <xsl:if test='not(.="none")'>
- <xsl:text>text-decoration:underline; </xsl:text>
- </xsl:if>
- </xsl:when>
- <xsl:when test='name(.)="style:text-position"'>
- <xsl:if test='contains(., "sub")'>
- <xsl:text>vertical-align:sub; </xsl:text>
- </xsl:if>
- <xsl:if test='contains(., "sup")'>
- <xsl:text>vertical-align:sup; </xsl:text>
- </xsl:if>
- </xsl:when>
- <!-- isDebugModeMESSAGE:
- <xsl:otherwise>
- <xsl:message>No transformation implemented for attribute-typ <xsl:value-of select="name(.)"/></xsl:message>
- </xsl:otherwise>-->
- </xsl:choose>
- </xsl:for-each>
- </xsl:when>
- <!--+++++ PALM 3.2 SUBSET AND WAP PROPERTIES +++++-->
- <xsl:otherwise>
- <xsl:for-each select="$styleAttributePath">
- <!-- isDebugModeMESSAGE:
- <xsl:message> Name:<xsl:value-of select="name()"/> Value:<xsl:value-of select="."/></xsl:message> -->
-
- <!-- BUG WORK AROUND:
- Due to a bug in the XT Processor, it is not possible to create serveral elements in variable and search over them,
- after explicit conversion to nodeset
- This generated sting identifier shall be later changed back to a set of elements
- -->
- <xsl:choose>
- <!--*** FORMAT ATTRIBUTES ***-->
-
- <!-- Italic -->
- <xsl:when test='name(.)="fo:font-style"'>
- <xsl:if test="contains(., 'italic') or contains(., 'oblique')">
- <xsl:text>italic, </xsl:text>
- </xsl:if>
- </xsl:when>
-
- <!-- Boldface -->
- <xsl:when test='name(.)="fo:font-weight"'>
- <xsl:if test="contains(., 'bold') or contains(., 'bolder')">
- <xsl:text>bold, </xsl:text>
- </xsl:if>
- </xsl:when>
-
- <!-- Underline -->
- <xsl:when test='name(.)="style:text-underline"'>
- <xsl:text>underline, </xsl:text>
- </xsl:when>
-
- <!-- Alignment -->
- <xsl:when test='name(.)="fo:text-align"'>
- <xsl:choose>
- <xsl:when test="contains(., 'start')">
- <xsl:text>align:left, </xsl:text>
- </xsl:when>
- <xsl:when test="contains(., 'end')">
- <xsl:text>align:right, </xsl:text>
- </xsl:when>
- <xsl:when test="contains(., 'center')">
- <xsl:text>align:center, </xsl:text>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
-
- <!-- strikethrough -->
- <xsl:when test='name(.)="style:text-crossing-out"'>
- <xsl:text>strike, </xsl:text>
- </xsl:when>
-
- <!-- Font - size (Palm: emulator transformed sizes to available set (e.g. 30 to (probably) 9)-->
- <xsl:when test='name(.)="fo:font-size"'>
- <xsl:text>size:</xsl:text><xsl:value-of select="."/><xsl:text>:size, </xsl:text>
- </xsl:when>
-
- <!-- Font - Color (PALM: but mostly only 2 available)
- black (#000000)
- gray (#808080)(rendered as dark gray)
- silver (#C0C0C0)(rendered as light gray)
- white (#FFFFFF)-->
- <xsl:when test='name(.)="fo:color"'>
- <xsl:choose>
- <xsl:when test="contains(. , '#FFFFFF') or contains(. , '#ffffff') or contains(. , 'white') or contains(. , 'WHITE')">
- <xsl:text>color:#FFFFFF, </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>color:#000000, </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
-
-
- <!--*** TABLE ATTRIBUTES ***-->
- <xsl:when test='name(.)="fo:font-size"'>
- <xsl:text>size:</xsl:text><xsl:value-of select="."/><xsl:text>:size, </xsl:text>
- </xsl:when>
- <xsl:when test='name(.)="style:column-width"'>
- <xsl:choose>
- <!-- changing the distance measure: inch to in -->
- <xsl:when test="contains(., 'ch')">
- <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>:width, </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>:width; </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test='name(.)="style:row-height"'>
- <xsl:choose>
- <!-- changing the distance measure: inch to in -->
- <xsl:when test="contains(., 'ch')">
- <xsl:text>height:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>:height; </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>height:</xsl:text><xsl:value-of select="."/><xsl:text>:height; </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test='name(.)="style:width"'> <!--earlier fo:width-->
- <xsl:choose>
- <!-- changing the distance measure: inch to in -->
- <xsl:when test="contains(., 'ch')">
- <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>:width; </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>:width; </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- </xsl:choose>
- </xsl:for-each>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
-<!-- 2DO: NAMING CONVENTION variable are written with '-' instead of case-sensitive writing -->
-
-
-
- <!-- ***** MEASUREMENT CONVERSIONS *****
-
- * 1 centimeter = 10 mm
-
- * 1 inch = 25.4 mm
- While the English have already seen the light (read: the metric system), the US
- remains loyal to this medieval system.
-
- * 1 didot point = 0.376065 mm
- The didot system originated in France but was used in most of Europe
-
- * 1 pica point = 0.35146 mm
- The Pica points system was developed in England and is used in Great-Britain and the US.
-
- * 1 PostScript point = 0.35277138 mm
- When Adobe created PostScript, they added their own system of points.
- There are exactly 72 PostScript points in 1 inch.
-
- * 1 pixel = 0.26458333.. mm (by 96 dpi)
- Most pictures have the 96 dpi resolution, but the dpi variable may vary by stylesheet parameter
- -->
-
-
- <!-- changing measure to mm -->
- <xsl:template name="convert2mm">
- <xsl:param name="value"/>
-
- <xsl:param name="centimeter-in-mm" select="10"/>
- <xsl:param name="inch-in-mm" select="25.4"/>
- <xsl:param name="didot-point-in-mm" select="0.376065"/>
- <xsl:param name="pica-point-in-mm" select="0.35146"/>
-
- <xsl:choose>
- <xsl:when test="contains($value, 'cm')">
- <xsl:value-of select="round(number(substring-before($value,'cm' )) * $centimeter-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'in')">
- <xsl:value-of select="round(number(substring-before($value,'in' )) * $inch-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'dpt')">
- <xsl:value-of select="round(number(substring-before($value,'dpt')) * $didot-point-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'ppt')">
- <xsl:value-of select="round(number(substring-before($value,'ppt')) * $pica-point-in-mm)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- changing measure to cm -->
- <xsl:template name="convert2cm">
- <xsl:param name="value"/>
-
- <xsl:param name="centimeter-in-mm" select="10"/>
- <xsl:param name="inch-in-mm" select="25.4"/>
- <xsl:param name="didot-point-in-mm" select="0.376065"/>
- <xsl:param name="pica-point-in-mm" select="0.35146"/>
-
- <xsl:choose>
- <xsl:when test="contains($value, 'mm')">
- <xsl:value-of select="round(number(substring-before($value, 'mm')) div $centimeter-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'in')">
- <xsl:value-of select="round(number(substring-before($value, 'in')) div $centimeter-in-mm * $inch-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'dpt')">
- <xsl:value-of select="round(number(substring-before($value,'dpt')) div $centimeter-in-mm * $didot-point-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'ppt')">
- <xsl:value-of select="round(number(substring-before($value,'ppt')) div $centimeter-in-mm * $pica-point-in-mm)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- changing measure to inch (cp. section comment) -->
- <xsl:template name="convert2inch">
- <xsl:param name="value"/>
-
- <xsl:param name="centimeter-in-mm" select="10"/>
- <xsl:param name="inch-in-mm" select="25.4"/>
- <xsl:param name="didot-point-in-mm" select="0.376065"/>
- <xsl:param name="pica-point-in-mm" select="0.35146"/>
-
- <xsl:choose>
- <xsl:when test="contains($value, 'mm')">
- <xsl:value-of select="round(number(substring-before($value, 'mm')) div $inch-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'cm')">
- <xsl:value-of select="round(number(substring-before($value, 'cm')) div $inch-in-mm * $centimeter-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'dpt')">
- <xsl:value-of select="round(number(substring-before($value,'dpt')) div $inch-in-mm * $didot-point-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'ppt')">
- <xsl:value-of select="round(number(substring-before($value,'ppt')) div $inch-in-mm * $pica-point-in-mm)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- changing measure to dpt (cp. section comment) -->
- <xsl:template name="convert2dpt">
- <xsl:param name="value"/>
-
- <xsl:param name="centimeter-in-mm" select="10"/>
- <xsl:param name="inch-in-mm" select="25.4"/>
- <xsl:param name="didot-point-in-mm" select="0.376065"/>
- <xsl:param name="pica-point-in-mm" select="0.35146"/>
-
- <xsl:choose>
- <xsl:when test="contains($value, 'mm')">
- <xsl:value-of select="round(number(substring-before($value, 'mm')) div $didot-point-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'cm')">
- <xsl:value-of select="round(number(substring-before($value, 'cm')) div $didot-point-in-mm * $centimeter-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'in')">
- <xsl:value-of select="round(number(substring-before($value, 'in')) div $didot-point-in-mm * $inch-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'ppt')">
- <xsl:value-of select="round(number(substring-before($value,'ppt')) div $didot-point-in-mm * $pica-point-in-mm)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$value"/>
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:template>
-
-
- <!-- changing measure to ppt (cp. section comment) -->
- <xsl:template name="convert2ppt">
- <xsl:param name="value"/>
-
- <xsl:param name="centimeter-in-mm" select="10"/>
- <xsl:param name="inch-in-mm" select="25.4"/>
- <xsl:param name="didot-point-in-mm" select="0.376065"/>
- <xsl:param name="pica-point-in-mm" select="0.35146"/>
-
- <xsl:choose>
- <xsl:when test="contains($value, 'mm')">
- <xsl:value-of select="round(number(substring-before($value, 'mm')) div $pica-point-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'cm')">
- <xsl:value-of select="round(number(substring-before($value, 'cm')) div $pica-point-in-mm * $centimeter-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'in')">
- <xsl:value-of select="round(number(substring-before($value, 'in')) div $pica-point-in-mm * $inch-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'dpt')">
- <xsl:value-of select="round(number(substring-before($value,'dpt')) div $pica-point-in-mm * $didot-point-in-mm)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- changing measure to pixel by via parameter provided dpi (dots per inch) standard factor (cp. section comment) -->
- <xsl:template name="convert2pixel">
- <xsl:param name="value"/>
-
- <xsl:param name="centimeter-in-mm" select="10"/>
- <xsl:param name="inch-in-mm" select="25.4"/>
- <xsl:param name="didot-point-in-mm" select="0.376065"/>
- <xsl:param name="pica-point-in-mm" select="0.35146"/>
- <xsl:param name="pixel-in-mm" select="$inch-in-mm div $dpi"/>
-
- <xsl:choose>
- <xsl:when test="contains($value, 'mm')">
- <xsl:value-of select="round(number(substring-before($value, 'mm')) div $pixel-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'cm')">
- <xsl:value-of select="round(number(substring-before($value, 'cm')) div $pixel-in-mm * $centimeter-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'in')">
- <xsl:value-of select="round(number(substring-before($value, 'in')) div $pixel-in-mm * $inch-in-mm)"/>
- </xsl:when>
- <xsl:when test="contains($value, 'dpt')">
- <xsl:value-of select="round(number(substring-before($value,'dpt')) div $pixel-in-mm * $didot-point-in-mm)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-<!--
-
- The Contents of this file are made available subject to the terms of
- either of the following licenses
-
- - GNU Lesser General Public License Version 2.1
- - Sun Industry Standards Source License Version 1.1
-
- Sun Microsystems Inc., October, 2000
-
- GNU Lesser General Public License Version 2.1
- =============================================
- Copyright 2000 by Sun Microsystems, Inc.
- 901 San Antonio Road, Palo Alto, CA 94303, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License version 2.1, as published by the Free Software Foundation.
-
- 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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
-
-
- Sun Industry Standards Source License Version 1.1
- =================================================
- The contents of this file are subject to the Sun Industry Standards
- Source License Version 1.1 (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.openoffice.org/license.html.
-
- Software provided under this License is provided on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- See the License for the specific provisions governing your rights and
- obligations concerning the Software.
-
- The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-
- Copyright © 2002 by Sun Microsystems, Inc.
-
- All Rights Reserved.
-
- Contributor(s): _______________________________________
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="http://openoffice.org/2000/office"
- xmlns:style="http://openoffice.org/2000/style"
- xmlns:text="http://openoffice.org/2000/text"
- xmlns:table="http://openoffice.org/2000/table"
- xmlns:draw="http://openoffice.org/2000/drawing"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:number="http://openoffice.org/2000/datastyle"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:chart="http://openoffice.org/2000/chart"
- xmlns:dr3d="http://openoffice.org/2000/dr3d"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="http://openoffice.org/2000/form"
- xmlns:script="http://openoffice.org/2000/script"
- office:class="text"
- office:version="1.0"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:meta="http://openoffice.org/2000/meta"
- xmlns:config="http://openoffice.org/2001/config"
- xmlns:help="http://openoffice.org/2000/help"
- xmlns:xt="http://www.jclark.com/xt"
- xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:java="http://xml.apache.org/xslt/java"
- exclude-result-prefixes="java">
-
-
- <!-- table row handling -->
- <xsl:include href="table_rows.xsl"/>
- <!-- table column handling -->
- <xsl:include href="table_columns.xsl"/>
- <!-- table cell handling -->
- <xsl:include href="table_cells.xsl"/>
-
-
-
- <!-- ******************* -->
- <!-- *** main table *** -->
- <!-- ******************* -->
-
- <xsl:template match="table:table | table:sub-table">
- <xsl:param name="collectedGlobalData"/>
-
- <!-- a table will only be created if the "scenario" is active -->
- <xsl:if test="string-length(table:scenario/@table:is-active) = 0">
- <!-- collecting all visible "table:table-row" elements of the table -->
- <xsl:variable name="allVisibleTableRows" select="table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]
- | table:table-header-rows/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]
- | table:table-row-group/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]"/>
- <xsl:choose>
- <!-- for all but WAP/WML devices a table border check is done (cp. "check-for-table-border") -->
- <xsl:when test="not($outputType = 'WML')">
-
- <!-- As the alignment of a table is by 'align' attribut is deprecated and as the CSS 'float' attribute not well displayed,
- we do a little trick by encapsulating the table with a aligned 'div' element-->
- <xsl:variable name="table-alignment" select="$office:automatic-styles/style:style[@style:name = current()/@table:style-name]/style:properties/@table:align"/>
-
- <xsl:choose>
- <xsl:when test="string-length($table-alignment) != 0">
- <xsl:element name="div">
- <xsl:attribute name="align">
- <xsl:choose>
- <xsl:when test='$table-alignment="left" or $table-alignment="margins"'>
- <xsl:text>left</xsl:text>
- </xsl:when>
- <xsl:when test='$table-alignment="right"'>
- <xsl:text>right</xsl:text>
- </xsl:when>
- <xsl:when test='$table-alignment="center"'>
- <xsl:text>center</xsl:text>
- </xsl:when>
- </xsl:choose>
- </xsl:attribute>
- <xsl:element name="table">
-
- <xsl:apply-templates select="@table:style-name">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
-
- <!-- workaround, set table border attribut if any cell-border exists
- <xsl:call-template name="check-for-table-border">
- <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
- </xsl:call-template> -->
- <xsl:call-template name="create-column-style-variable">
- <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:element>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="table">
- <xsl:apply-templates select="@table:style-name">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
-
- <!-- workaround, set table border attribut if any cell-border exists
- <xsl:call-template name="check-for-table-border">
- <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
- </xsl:call-template> -->
- <xsl:call-template name="create-column-style-variable">
- <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:when>
- <xsl:otherwise>
- <!-- for WML devices only ASCII table are written as tables are not implemented widley.
- Beginning from 'repeat-write-row' the templates are handled by the table_wml.xsl stylesheet -->
- <xsl:call-template name="create-column-style-variable">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- </xsl:template>
-
-
-
- <xsl:template name="create-column-style-variable">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="allVisibleTableRows"/>
-
- <!-- all columns of the table -->
- <xsl:variable name="allTableColumns" select="table:table-column |
- table:table-column-group/descendant::table:table-column |
- table:table-header-columns/descendant::table:table-column"/>
- <!-- allColumnStyleEntries: Containing all columns of the table, hidden and viewed.
- - if a column is hidden, it contains the hidden attribute, otherwise the style-properties will be stored
- - if a column is being repeated, each repeated column is explicitly written as entry in this variable.
- Later (during template "write-cell") the style of the column will be mixed with the cell-style by using
- the position() of the column entry and comparing it with the iterating cell number. -->
- <xsl:variable name="allColumnStyleEntries-RTF">
- <xsl:call-template name="adding-column-styles-entries">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allTableColumns" select="$allTableColumns"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="function-available('xt:node-set')">
- <xsl:call-template name="create-table">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
- <xsl:with-param name="allColumnStyleEntries" select="xt:node-set($allColumnStyleEntries-RTF)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="function-available('xalan:nodeset')">
- <xsl:call-template name="create-table">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
- <xsl:with-param name="allColumnStyleEntries" select="xalan:nodeset($allColumnStyleEntries-RTF)"/>
- </xsl:call-template>
- </xsl:when>
- </xsl:choose>
-
- </xsl:template>
-
-
-
- <xsl:template name="create-table">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="allVisibleTableRows"/>
- <xsl:param name="allColumnStyleEntries"/>
-
-
- <!-- Some Office Calc documents simulate a background by repeating the last cell until end of space
- (The value of "table:number-columns-repeated" is enourmous). Writing out all these cells would be fatal.
- Therefore, this global variable shows us the longest row with content.
-
- Earlier only the viewable columns were listed, but it is easier to handle with all columns:
- <xsl:variable name="maxRowLength" select="count($allColumnStyleEntries/column-style-entry[not(@column-hidden-flag)])"/> -->
- <xsl:variable name="maxRowLength" select="count($allColumnStyleEntries/column-style-entry)"/>
-
-
- <!--isDebugMode-START-->
- <xsl:if test="$isDebugMode">
- <xsl:message>maxRowLength: <xsl:value-of select="$maxRowLength"/></xsl:message>
- <xsl:variable name="numberOfHiddenColumns" select="count($allColumnStyleEntries/column-style-entry[@column-hidden-flag])"/>
- <xsl:message>numberOfHiddenColumns: <xsl:value-of select="$numberOfHiddenColumns"/></xsl:message>
- <xsl:call-template name="table-debug-allColumnStyleEntries">
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- </xsl:call-template>
- </xsl:if>
- <!--isDebugMode-END-->
- <xsl:choose>
- <xsl:when test="$outputType = 'WML'">
- <!-- matching all rows - we can not use xsl:apply-template with a node-set parameter as by a bug in XT (James Clark)
- (here: allColumnStyleEntries) will be interpreted as a result tree fragment, where no search expression (XPath) can be used
- 2DO:CHECK WITH XALAN-->
- <xsl:for-each select="$allVisibleTableRows">
- <xsl:call-template name="wml-repeat-write-row">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="number-rows-repeated" select="@table:number-rows-repeated"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <!-- matching all rows - we can not use xsl:apply-template with a node-set parameter as by a bug in XT (James Clark)
- (here: allColumnStyleEntries) will be interpreted as a result tree fragment, where no search expression (XPath) can be used
- 2DO:CHECK WITH XALAN -->
- <xsl:for-each select="$allVisibleTableRows">
- <xsl:call-template name="repeat-write-row">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="number-rows-repeated" select="@table:number-rows-repeated"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
-
-
- <!-- **************************** -->
- <!-- *** HELPER: table border *** -->
- <!-- **************************** -->
-
- <!-- only one table border for HTML4 or CSS devices which contain one or more 'fo:border-top' attributes (pars pro toto, if one exist the other usually exist, too) -->
- <!-- this was a work-around for the netscape 4.xx but not longer necessary for Mozilla -->
- <xsl:template name="check-for-table-border">
- <xsl:param name="allVisibleTableRows"/>
-
- <xsl:variable name="startTime">
- <xsl:if test="$isDebugMode and not($isJavaDisabled)">
- <xsl:choose>
- <xsl:when test="function-available('system:current-time-millis')">
- <xsl:value-of select="system:current-time-millis()"/>
- </xsl:when>
- <xsl:when test="function-available('java:java.lang.System.currentTimeMillis')">
- <xsl:value-of select="java:java.lang.System.currentTimeMillis()"/>
- </xsl:when>
- </xsl:choose>
- </xsl:if>
- </xsl:variable>
-
- <!-- checks if one cell (table:table-cell) of the rows of this table (allVisibleTableRows) contains a border style (i.e. fo:border-top)
- If only one single border element exist, the whole table will gets pre-defined borders (simple heuristic for better browser display) -->
- <xsl:if test="$allVisibleTableRows/table:table-cell[@table:style-name=/*/*/style:style[style:properties/@fo:border-top]/@style:name]">
- <xsl:attribute name="border">1</xsl:attribute>
- <xsl:attribute name="bordercolor">#000000</xsl:attribute>
- <xsl:attribute name="cellpadding">2</xsl:attribute>
- <xsl:attribute name="cellspacing">0</xsl:attribute>
- <xsl:attribute name="page-break-inside">page-break-inside:avoid</xsl:attribute>
- </xsl:if>
-
-
- <!-- check the time for borderchecking (debug)-->
- <xsl:if test="$isDebugMode and not($isJavaDisabled)">
- <xsl:variable name="endTime">
- <xsl:choose>
- <xsl:when test="function-available('system:current-time-millis')">
- <xsl:value-of select="system:current-time-millis()"/>
- </xsl:when>
- <xsl:when test="function-available('java:java.lang.System.currentTimeMillis')">
- <xsl:value-of select="java:java.lang.System.currentTimeMillis()"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
- <xsl:message>Time for checking BorderStyle: <xsl:value-of select="($endTime - $startTime)"/> ms</xsl:message>
- </xsl:if>
- </xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-<!--
-
- The Contents of this file are made available subject to the terms of
- either of the following licenses
-
- - GNU Lesser General Public License Version 2.1
- - Sun Industry Standards Source License Version 1.1
-
- Sun Microsystems Inc., October, 2000
-
- GNU Lesser General Public License Version 2.1
- =============================================
- Copyright 2000 by Sun Microsystems, Inc.
- 901 San Antonio Road, Palo Alto, CA 94303, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License version 2.1, as published by the Free Software Foundation.
-
- 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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
-
-
- Sun Industry Standards Source License Version 1.1
- =================================================
- The contents of this file are subject to the Sun Industry Standards
- Source License Version 1.1 (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.openoffice.org/license.html.
-
- Software provided under this License is provided on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- See the License for the specific provisions governing your rights and
- obligations concerning the Software.
-
- The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-
- Copyright © 2002 by Sun Microsystems, Inc.
-
- All Rights Reserved.
-
- Contributor(s): _______________________________________
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="http://openoffice.org/2000/office"
- xmlns:style="http://openoffice.org/2000/style"
- xmlns:text="http://openoffice.org/2000/text"
- xmlns:table="http://openoffice.org/2000/table"
- xmlns:draw="http://openoffice.org/2000/drawing"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:number="http://openoffice.org/2000/datastyle"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:chart="http://openoffice.org/2000/chart"
- xmlns:dr3d="http://openoffice.org/2000/dr3d"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="http://openoffice.org/2000/form"
- xmlns:script="http://openoffice.org/2000/script"
- office:class="text"
- office:version="1.0"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:meta="http://openoffice.org/2000/meta"
- xmlns:config="http://openoffice.org/2001/config"
- xmlns:help="http://openoffice.org/2000/help"
- xmlns:xt="http://www.jclark.com/xt"
- xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:java="http://xml.apache.org/xslt/java"
- exclude-result-prefixes="java">
-
-
- <!-- *********************************** -->
- <!-- *** write repeating table cells *** -->
- <!-- *********************************** -->
-
-
- <!-- matching cells to give out -> covered table cells are not written out -->
- <xsl:template match="table:table-cell">
- <xsl:param name="collectedGlobalData"/>
- <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
- <xsl:param name="allColumnStyleEntries"/>
- <xsl:param name="maxRowLength"/>
-
- <xsl:if test="$isDebugMode">
- <xsl:message>
---------------> table:table-cell has been entered with node value: <xsl:value-of select="."/></xsl:message>
- <xsl:message>table:number-columns-repeated: -<xsl:value-of select="@table:number-columns-repeated"/>-</xsl:message>
- </xsl:if>
-
- <xsl:call-template name="create-column-position-variable">
- <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- </xsl:call-template>
-
- </xsl:template>
-
-
-
- <xsl:template name="create-column-position-variable">
- <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
- <xsl:param name="allColumnStyleEntries"/>
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="maxRowLength"/>
-
- <!-- column position needed for styles, esp. for column-hidden-flag -->
- <xsl:variable name="preceding-columns">
- <xsl:for-each select="preceding-sibling::*">
- <xsl:element name="quantity">
- <xsl:choose>
- <xsl:when test="string-length(@table:number-columns-repeated) = 0">1</xsl:when>
- <xsl:otherwise><xsl:value-of select="@table:number-columns-repeated"/></xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:for-each>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="function-available('xt:node-set')">
- <xsl:call-template name="create-table-cell">
- <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- <xsl:with-param name="column-position" select="sum(xt:node-set($preceding-columns)/quantity) + 1"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="function-available('xalan:nodeset')">
- <xsl:call-template name="create-table-cell">
- <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- <xsl:with-param name="column-position" select="sum(xalan:nodeset($preceding-columns)/quantity) + 1"/>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:element name="NodeSetFunctionNotAvailable"/>
- <xsl:call-template name="create-table-cell"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <xsl:template name="create-table-cell">
- <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
- <xsl:param name="allColumnStyleEntries"/>
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="maxRowLength"/>
- <xsl:param name="column-position"/>
-
-
- <xsl:if test="$isDebugMode">
- <xsl:message>NEW VALUE: column-position: -<xsl:value-of select="$column-position"/>-</xsl:message>
- </xsl:if>
-
-
- <!-- a hidden column will give out nothing -->
- <xsl:if test="not($allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag)">
- <xsl:choose>
- <!-- when the columns are not repeated the next column-positions raises up to 1, otherwise up to the amount of repeated columns -->
- <xsl:when test="@table:number-columns-repeated">
- <!-- writes multiple entries of a cell -->
- <xsl:call-template name="repeat-write-cell">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="column-position" select="$column-position"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- <xsl:with-param name="number-columns-repeated" select="@table:number-columns-repeated"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <!-- writes an entry of a cell -->
- <xsl:call-template name="write-cell">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="column-position" select="$column-position"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-
- </xsl:template>
-
-
-
- <xsl:template name="repeat-write-cell">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="allColumnStyleEntries"/>
- <xsl:param name="column-position"/>
- <xsl:param name="maxRowLength"/>
- <xsl:param name="number-columns-repeated"/>
-
- <xsl:choose>
- <!-- 2DO: This is the current workaround against the background simulation by an 'endless' repeating cell -->
- <xsl:when test="$number-columns-repeated > 1 and $maxRowLength > $column-position">
-
- <xsl:if test="$isDebugMode">
- <xsl:message>+++++++++ starting cell writing +++++++++</xsl:message>
- <xsl:message>number-columns-repeated: -<xsl:value-of select="$number-columns-repeated"/>-</xsl:message>
- <xsl:message>maxRowLength: -<xsl:value-of select="$maxRowLength"/>-</xsl:message>
- <xsl:message>column-position: -<xsl:value-of select="$column-position"/>-</xsl:message>
- </xsl:if>
-
- <!-- writes an entry of a cell -->
- <xsl:call-template name="write-cell">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="column-position" select="$column-position"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- </xsl:call-template>
- <!-- repeat calling this method until all elements written out -->
- <xsl:if test="$isDebugMode">
- <xsl:message>+++++++++ cell repetition +++++++++</xsl:message>
- </xsl:if>
- <xsl:call-template name="repeat-write-cell">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="column-position" select="$column-position + 1"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- <xsl:with-param name="number-columns-repeated" select="$number-columns-repeated - 1"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <!-- 2DO: This is the current workaround against the background simulation by an 'endless' repeating cell -->
- <!-- When the maxRowLength is reached a last entry of a cell is written -->
- <xsl:call-template name="write-cell">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="column-position" select="$column-position"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <xsl:template name="write-cell">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="allColumnStyleEntries"/>
- <xsl:param name="column-position"/>
- <xsl:param name="maxRowLength"/>
-
-
- <xsl:if test="$isDebugMode">
- <xsl:message>WriteTest -> If nothing between '-' write cell -<xsl:value-of select="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag"/>-</xsl:message>
- </xsl:if>
-
- <xsl:if test="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag">
- <xsl:if test="$isDebugMode">
- <xsl:message>TABLE COLUMN is hidden!</xsl:message>
- </xsl:if>
- </xsl:if>
-
- <xsl:choose>
- <!-- a hidden column will give out nothing -->
- <xsl:when test="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag">
- <xsl:if test="$isDebugMode">
- <xsl:message>TABLE COLUMN is hidden!</xsl:message>
- </xsl:if>
- </xsl:when>
-
- <!-- NOT a hidden column -->
- <xsl:otherwise>
-
- <!-- a table is a table header, when it has a "table:table-header-rows" ancestor -->
- <xsl:variable name="tableDataType">
- <xsl:choose>
- <xsl:when test="ancestor::table:table-header-rows">
- <xsl:text>th</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>td</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER'">
- <xsl:element name="{$tableDataType}">
-
- <xsl:if test="$isDebugMode">
- <xsl:message>
-*****************************************'<xsl:value-of select="$tableDataType"/>' element has been added!</xsl:message>
- </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>
-
-
-
- <!-- *** the cell-style *** -->
- <!-- The cell style has no conclusion with the column style, so we switch the order/priorities due to browser issues
-
- The cell-style depends on two attributes:
-
- 1) table:style-name - the style properties of cell. When they exist, a default alignement (cp. below) will be added for the
- case of no alignment in the style exist.
-
- 2) table:value-type - the value type of the table-cell giving the default alignments.
- By default a string value is left aligned, all other are aligned:right.
- -->
- <xsl:choose>
- <xsl:when test="@table:style-name">
- <xsl:attribute name="style">
-
- <!-- CELL-STYLE: alignment by table:value-type (without existing table:style-name)-->
- <xsl:variable name="cellStyle" select="$collectedGlobalData/allstyles/*[name()=current()/@table:style-name]"/>
- <xsl:choose>
- <xsl:when test="string-length($cellStyle) > 0 and not(contains($cellStyle, 'text-align'))">
- <!-- CELL-STYLE: alignment by table:value-type -->
- <!-- no alignment in the cell style, the alignment based on the table:value-type will be added -->
- <xsl:choose>
- <xsl:when test="@table:value-type and not(@table:value-type = 'string')">
- <xsl:value-of select="concat($collectedGlobalData/allstyles/*[name()=current()/@table:style-name], 'text-align:right; ')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat($collectedGlobalData/allstyles/*[name()=current()/@table:style-name], 'text-align:left; ')"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <!-- CELL-STYLE: alignment by table:value-type -->
- <!-- no CSS style properties exist, only alignment from the table:value-type will be used -->
- <xsl:choose>
- <xsl:when test="@table:value-type and not(@table:value-type = 'string')">text-align:right; </xsl:when>
- <xsl:otherwise>text-align:left; </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-
- <!-- column-style (disjunct of cell style -->
- <!-- 2DO: only absolut styles are supported, relative styles (i.e. 'style:rel-column-width' e.g. with value "8933*" are ignored.
- Issue: browsers (not sure if CSS) does not support the '*' relationship, only the '%', where the sum is always '100'!
- For this, it is easier to work on with the absolute values, instead of calculating the values for 100% -->
- <xsl:value-of select="$allColumnStyleEntries/column-style-entry[position()=$column-position]"/>
- </xsl:attribute>
- <!-- CELL-STYLE: table:style-name -->
- <xsl:attribute name="class">
- <xsl:value-of select="translate(@table:style-name, '. %()/\', '')"/>
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="style">
- <!-- CELL-STYLE: alignment by table:value-type (without existing table:style-name)-->
- <!-- no table:style-name exist, only alignment from the table:value-type will be used -->
- <xsl:choose>
- <xsl:when test="@table:value-type and not(@table:value-type = 'string')">
- text-align:right;
- </xsl:when>
- <xsl:otherwise>
- text-align:left;
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:choose>
- <!-- In case of no cell content a non-breakable space will be inserted
- to make the browser show the table-cell grid -->
- <xsl:when test="not(child::text()) and not(child::*)">
- <xsl:text>  </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <!-- *** the column-style *** -->
- <!-- the column style has no conclusion with the cell style, so we switch the order/priorities due to browser issues-->
- <xsl:element name="span">
- <xsl:attribute name="class">
- <xsl:value-of select="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@style-name"/>
- </xsl:attribute>
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:when>
-
- <!--+++++ HTML 4.0 INLINED WAY +++++-->
- <xsl:when test="$outputType = 'CSS_INLINED'">
- <xsl:element name="{$tableDataType}">
-
- <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:attribute name="style">
- <!-- cell-style -->
- <xsl:value-of select="$collectedGlobalData/allstyles/*[name()=current()/@table:style-name]"/>
- <!-- column-style -->
- <xsl:value-of select="$allColumnStyleEntries/column-style-entry[position()=$column-position]"/>
- <!-- TABLE:VALUE-TYPE - the value of a table-cell will be aligned left by default only exlicit non-string is aligned:right-->
- <xsl:choose>
- <xsl:when test="@table:value-type and not(@table:value-type = 'string')">
- <xsl:text>text-align:right;</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>text-align:left;</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
-
- <!--   is a non-breakable space, necessary to make to the browser show the table-cell grid -->
- <xsl:if test="not(child::text()) and not(child::*)">  </xsl:if>
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
- <!--+++++ PALM INLINED WAY +++++-->
- <xsl:when test="$outputType = 'PALM'">
- <xsl:element name="{$tableDataType}">
- <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>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
- <!--+++++ WML WAY +++++-->
- <xsl:when test="$outputType = 'WML'">
- <xsl:choose>
- <xsl:when test="not($allColumnStyleEntries/column-style-entry[last() = $column-position])">
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- <xsl:text>, </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:apply-templates>
- <xsl:text>; </xsl:text>
- <xsl:element name="br"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-</xsl:stylesheet>
+++ /dev/null
-<!--
-
- The Contents of this file are made available subject to the terms of
- either of the following licenses
-
- - GNU Lesser General Public License Version 2.1
- - Sun Industry Standards Source License Version 1.1
-
- Sun Microsystems Inc., October, 2000
-
- GNU Lesser General Public License Version 2.1
- =============================================
- Copyright 2000 by Sun Microsystems, Inc.
- 901 San Antonio Road, Palo Alto, CA 94303, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License version 2.1, as published by the Free Software Foundation.
-
- 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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
-
-
- Sun Industry Standards Source License Version 1.1
- =================================================
- The contents of this file are subject to the Sun Industry Standards
- Source License Version 1.1 (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.openoffice.org/license.html.
-
- Software provided under this License is provided on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- See the License for the specific provisions governing your rights and
- obligations concerning the Software.
-
- The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-
- Copyright © 2002 by Sun Microsystems, Inc.
-
- All Rights Reserved.
-
- Contributor(s): _______________________________________
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="http://openoffice.org/2000/office"
- xmlns:style="http://openoffice.org/2000/style"
- xmlns:text="http://openoffice.org/2000/text"
- xmlns:table="http://openoffice.org/2000/table"
- xmlns:draw="http://openoffice.org/2000/drawing"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:number="http://openoffice.org/2000/datastyle"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:chart="http://openoffice.org/2000/chart"
- xmlns:dr3d="http://openoffice.org/2000/dr3d"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="http://openoffice.org/2000/form"
- xmlns:script="http://openoffice.org/2000/script"
- office:class="text"
- office:version="1.0"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:meta="http://openoffice.org/2000/meta"
- xmlns:config="http://openoffice.org/2001/config"
- xmlns:help="http://openoffice.org/2000/help"
- xmlns:xt="http://www.jclark.com/xt"
- xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:java="http://xml.apache.org/xslt/java"
- exclude-result-prefixes="java">
-
-
- <!-- ******************************************** -->
- <!-- *** Create table columns style variable *** -->
- <!-- ******************************************** -->
-
- <xsl:template name="adding-column-styles-entries">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="allTableColumns"/>
-
- <xsl:for-each select="$allTableColumns">
-
- <xsl:variable name="column-style-entry" select="$collectedGlobalData/allstyles/*[name() = translate(current()/@table:style-name, '. %()/\', '')]"/>
- <xsl:choose>
- <xsl:when test="not(@table:number-columns-repeated)">
- <!-- writes an entry of a column in the columns-variable -->
- <xsl:call-template name="adding-column-style-entry">
- <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
- </xsl:call-template>
- </xsl:when>
- <!-- No higher repetition of cells greater than 4 for the last and second last column -->
- <!-- a hack for the sample document 'Waehrungsumrechner.sxc having 230 repeated columns in the second last column -->
- <!-- ??? <xsl:when test="(position() = last() or (position() = (last() - 1)) and @table:number-columns-repeated < 5)"> ???-->
- <xsl:when test="position() = last() or position() = (last() - 1)">
- <xsl:if test="@table:number-columns-repeated < 5">
- <!-- writes an entry of a column in the columns-variable -->
- <xsl:call-template name="repeat-adding-column-style-entry">
- <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
- <xsl:with-param name="number-columns-repeated" select="1"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <!-- repeated colums will be written explicit several times in the variable-->
- <xsl:call-template name="repeat-adding-column-style-entry">
- <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
- <xsl:with-param name="number-columns-repeated" select="@table:number-columns-repeated"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:template>
-
-
- <!-- WRITES THE REPEATED COLUMN STYLE EXPLICIT AS AN ELEMENT IN THE COLUMNS-VARIABLE -->
- <xsl:template name="repeat-adding-column-style-entry">
- <xsl:param name="column-style-entry"/>
- <xsl:param name="number-columns-repeated"/>
-
- <xsl:choose>
- <xsl:when test="$number-columns-repeated > 1">
- <!-- writes an entry of a column in the columns-variable -->
- <xsl:call-template name="adding-column-style-entry">
- <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
- </xsl:call-template>
- <!-- repeat calling this method until all elements written out -->
- <xsl:call-template name="repeat-adding-column-style-entry">
- <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
- <xsl:with-param name="number-columns-repeated" select="$number-columns-repeated - 1"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <!-- writes an entry of a column in the columns-variable -->
- <xsl:call-template name="adding-column-style-entry">
- <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- THE COLUMN-STYLE WRITE-PATTERN FOR EACH COLUMN WRITTEN IN A VARIABLE -->
- <xsl:template name="adding-column-style-entry">
- <xsl:param name="column-style-entry"/>
-
- <xsl:element name="column-style-entry">
- <xsl:choose>
- <xsl:when test="@table:visibility = 'collapse' or @table:visibility = 'filter'">
- <xsl:attribute name="column-hidden-flag">true</xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="table:style-name" select="translate(@table:style-name, '. %()/\', '')"/>
- <xsl:attribute name="style-name"><xsl:value-of select="$table:style-name"/></xsl:attribute>
- <xsl:value-of select="$column-style-entry"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:template>
-
-
-
- <!--isDebugMode-START-->
- <!-- giving out the 'allColumnStyle' variable:
- For each 'column-style-entry' of the 'allColumnStyleEntries' variable the style-name is given out.
- In case of 'column-hidden-flag' attribute the text 'Column is hidden is given out.-->
- <xsl:template name="table-debug-allColumnStyleEntries">
- <xsl:param name="allColumnStyleEntries"/>
-
- <!-- debug output as table summary attribut in html -->
- <xsl:attribute name="summary">
- <xsl:call-template name="table-debug-column-out">
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- </xsl:call-template>
- </xsl:attribute>
- <!-- debug output to console -->
- <xsl:message>
- <xsl:call-template name="table-debug-column-out">
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- </xsl:call-template>
- </xsl:message>
- </xsl:template>
-
-
- <xsl:template name="table-debug-column-out">
- <xsl:param name="allColumnStyleEntries"/>
- <xsl:text>
- DebugInformation: For each 'column-style-entry' of the 'allColumnStyleEntries' variable the style-name is given out.
- In case of 'column-hidden-flag' attribute the text 'column is hidden' is given out.
- </xsl:text>
- <xsl:for-each select="$allColumnStyleEntries/column-style-entry">
- <xsl:choose>
- <xsl:when test="@column-hidden-flag">
- <xsl:text> </xsl:text><xsl:value-of select="@style-name"/><xsl:text>column is hidden</xsl:text><xsl:text>
- </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text> </xsl:text><xsl:value-of select="@style-name"/><xsl:text> = </xsl:text><xsl:value-of select="."/><xsl:text>
- </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:template>
- <!--isDebugMode-END-->
-
-</xsl:stylesheet>
+++ /dev/null
-<!--
-
- The Contents of this file are made available subject to the terms of
- either of the following licenses
-
- - GNU Lesser General Public License Version 2.1
- - Sun Industry Standards Source License Version 1.1
-
- Sun Microsystems Inc., October, 2000
-
- GNU Lesser General Public License Version 2.1
- =============================================
- Copyright 2000 by Sun Microsystems, Inc.
- 901 San Antonio Road, Palo Alto, CA 94303, USA
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License version 2.1, as published by the Free Software Foundation.
-
- 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., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
-
-
- Sun Industry Standards Source License Version 1.1
- =================================================
- The contents of this file are subject to the Sun Industry Standards
- Source License Version 1.1 (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.openoffice.org/license.html.
-
- Software provided under this License is provided on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
- WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
- MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
- See the License for the specific provisions governing your rights and
- obligations concerning the Software.
-
- The Initial Developer of the Original Code is: Sun Microsystems, Inc.
-
- Copyright © 2002 by Sun Microsystems, Inc.
-
- All Rights Reserved.
-
- Contributor(s): _______________________________________
-
--->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:office="http://openoffice.org/2000/office"
- xmlns:style="http://openoffice.org/2000/style"
- xmlns:text="http://openoffice.org/2000/text"
- xmlns:table="http://openoffice.org/2000/table"
- xmlns:draw="http://openoffice.org/2000/drawing"
- xmlns:fo="http://www.w3.org/1999/XSL/Format"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:number="http://openoffice.org/2000/datastyle"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns:chart="http://openoffice.org/2000/chart"
- xmlns:dr3d="http://openoffice.org/2000/dr3d"
- xmlns:math="http://www.w3.org/1998/Math/MathML"
- xmlns:form="http://openoffice.org/2000/form"
- xmlns:script="http://openoffice.org/2000/script"
- office:class="text"
- office:version="1.0"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:meta="http://openoffice.org/2000/meta"
- xmlns:config="http://openoffice.org/2001/config"
- xmlns:help="http://openoffice.org/2000/help"
- xmlns:xt="http://www.jclark.com/xt"
- xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
- xmlns:xalan="http://xml.apache.org/xalan"
- xmlns:java="http://xml.apache.org/xslt/java"
- exclude-result-prefixes="java">
-
-
-
- <!-- ********************************************* -->
- <!-- *** write (explicit) repeating table rows *** -->
- <!-- ********************************************* -->
-
- <xsl:template name="repeat-write-row">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="allColumnStyleEntries"/>
- <xsl:param name="number-rows-repeated" select="1"/>
- <xsl:param name="maxRowLength"/>
-
- <xsl:choose>
- <!-- write an entry of a row and repeat calling this method until all elements are written out -->
- <xsl:when test="$number-rows-repeated > 1 and (table:table-cell/text() or table:table-cell/*)">
- <xsl:call-template name="write-row">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- </xsl:call-template>
-
- <!-- 2DO: take variable from the output of repeated write-row and iterate giving out the variable -->
- <xsl:call-template name="repeat-write-row">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- <xsl:with-param name="number-rows-repeated" select="$number-rows-repeated - 1"/>
- </xsl:call-template>
- </xsl:when>
- <!-- write a single entry of a row -->
- <xsl:otherwise>
- <xsl:call-template name="write-row">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <xsl:template name="write-row">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="allColumnStyleEntries"/>
- <xsl:param name="maxRowLength"/>
-
-
- <xsl:element name="tr">
- <!-- writing the style of the row -->
- <xsl:call-template name='add-style-properties'>
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- </xsl:call-template>
-
- <xsl:if test="$isDebugMode">
- <xsl:message>
-*************************'tr' element has been added!</xsl:message>
- </xsl:if>
-
- <xsl:apply-templates select="table:table-cell">
- <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
- <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
- <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
- </xsl:apply-templates>
-
- </xsl:element>
- </xsl:template>
-
-
- <!-- **************************** -->
- <!-- *** HELPER: table styles *** -->
- <!-- **************************** -->
-
- <xsl:template name="add-style-properties">
- <xsl:param name="collectedGlobalData"/>
- <xsl:param name="allColumnStyleEntries"/>
- <xsl:param name="node-position"/>
-
- <xsl:choose>
- <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
- <xsl:when test="$outputType = 'CSS_HEADER'">
- <xsl:attribute name="class">
- <xsl:value-of select="translate(@table:style-name, '. %()/\', '')"/>
- </xsl:attribute>
- </xsl:when>
-
- <!--+++++ HTML 4.0 INLINED WAY +++++-->
- <xsl:when test="$outputType = 'CSS_INLINED'">
- <xsl:attribute name="style">
- <xsl:value-of select="$collectedGlobalData/allstyles/*[name()=current()/@table:style-name]"/>
- </xsl:attribute>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Pdf class simply outputs the PDF file with the
- * content-type 'application/pdf' enabling web browsers with a PDF viewer
- * plugin to view the PDF file inside the browser.
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Pdf extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $this->_mimepart->getContents(),
- 'status' => array(),
- 'type' => 'application/pdf'
- )
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Php class renders out syntax-highlighted PHP code in
- * HTML format.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Php extends Horde_Mime_Viewer_Source
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => true,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- $ret = $this->_renderInline();
-
- // Need Horde headers for CSS tags.
- reset($ret);
- Horde::startBuffer();
- require $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc';
- echo $ret[key($ret)]['data'];
- require $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
- $ret[key($ret)]['data'] = Horde::endBuffer();
-
- return $ret;
- }
-
- /**
- * Return the rendered inline version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _renderInline()
- {
- $code = $this->_mimepart->getContents();
- if (strpos($code, '<?php') === false) {
- $text = str_replace('<?php ', '', highlight_string('<?php ' . $code, true));
- } else {
- $text = highlight_string($code, true);
- }
- $text = trim(str_replace(array("\n", '<br />'), array('', "\n"), $text));
- $text = $this->_lineNumber($text);
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $text,
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Plain class renders out plain text with URLs made
- * into hyperlinks (if viewing inline).
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => true,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- $text = $this->_mimepart->getContents();
- $charset = $this->_mimepart->getCharset();
-
- /* Check for 'flowed' text data. */
- if ($this->_mimepart->getContentTypeParameter('format') == 'flowed') {
- $text = $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp'));
- }
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => '<html><body><tt>' . Horde_Text_Filter::filter($text, 'text2html', array(
- 'charset' => $charset,
- 'parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL
- )) . '</tt></body></html>',
- 'status' => array(),
- 'type' => 'text/html; charset=' . $charset
- )
- );
- }
-
- /**
- * Return the rendered inline version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _renderInline()
- {
- $text = Horde_String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset());
-
- /* Check for 'flowed' text data. */
- $data = ($this->_mimepart->getContentTypeParameter('format') == 'flowed')
- ? $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp'))
- : $text;
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $data,
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-
- /**
- * Format flowed text for HTML output.
- *
- * @param string $text The text to format.
- * @param boolean $delsp Was text created with DelSp formatting?
- *
- * @return string The formatted text.
- */
- protected function _formatFlowed($text, $delsp = null)
- {
- $flowed = new Horde_Text_Flowed($this->_mimepart->replaceEOL($text, "\n"), $this->_mimepart->getCharset());
- $flowed->setMaxLength(0);
- if (!is_null($delsp)) {
- $flowed->setDelSp($delsp);
- }
- return $flowed->toFixed();
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Rar class renders out the contents of .rar archives
- * in HTML format.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @author Michael Cochrane <mike@graftonhall.co.nz>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => true,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Metadata for the current viewer/data.
- *
- * @var array
- */
- protected $_metadata = array(
- 'compressed' => true,
- 'embedded' => false,
- 'forceinline' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- $ret = $this->_renderInfo();
- if (!empty($ret)) {
- reset($ret);
- $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
- }
- return $ret;
- }
-
- /**
- * Return the rendered information about the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _renderInfo()
- {
- $contents = $this->_mimepart->getContents();
-
- $rar = Horde_Compress::factory('rar');
- $rarData = $rar->decompress($contents);
-
- $charset = $GLOBALS['registry']->getCharset();
- $fileCount = count($rarData);
-
- $name = $this->_mimepart->getName(true);
- if (empty($name)) {
- $name = _("unnamed");
- }
-
- $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
- '<table><tr><td align="left"><pre>' .
- Horde_Text_Filter::filter(_("Archive Name") . ': ' . $name, 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
- Horde_Text_Filter::filter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
- Horde_Text_Filter::filter(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) .
- "\n\n" .
- Horde_Text_Filter::filter(
- Horde_String::pad(_("File Name"), 50, ' ', STR_PAD_RIGHT) .
- Horde_String::pad(_("Attributes"), 10, ' ', STR_PAD_LEFT) .
- Horde_String::pad(_("Size"), 10, ' ', STR_PAD_LEFT) .
- Horde_String::pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) .
- Horde_String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) .
- Horde_String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT),
- 'space2html',
- array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
- str_repeat('-', 109) . "\n";
-
- foreach ($rarData as $val) {
- $ratio = empty($val['size'])
- ? 0
- : 100 * ($val['csize'] / $val['size']);
-
- $text .= Horde_Text_Filter::filter(
- Horde_String::pad($val['name'], 50, ' ', STR_PAD_RIGHT) .
- Horde_String::pad($val['attr'], 10, ' ', STR_PAD_LEFT) .
- Horde_String::pad($val['size'], 10, ' ', STR_PAD_LEFT) .
- Horde_String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT) .
- Horde_String::pad($val['method'], 10, ' ', STR_PAD_LEFT) .
- Horde_String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT),
- 'space2html',
- array('encode' => true, 'encode_all' => true)
- ) . "\n";
- }
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => nl2br($text . str_repeat('-', 106) . "\n</pre></td></tr></table>"),
- 'status' => array(),
- 'type' => 'text/html; charset=' . $charset
- )
- );
- }
-
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Report class is a wrapper used to load the
- * appropriate Horde_Mime_Viewer for multipart/report data (RFC 3462).
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Report extends Horde_Mime_Viewer_Driver
-{
- /**
- * Return the underlying MIME Viewer for this part.
- *
- * @return mixed A Horde_Mime_Viewer object, or false if not found.
- */
- protected function _getViewer()
- {
- if (!($type = $this->_mimepart->getContentTypeParameter('report-type'))) {
- /* This is a broken RFC 3462 message, since 'report-type' is
- * mandatory. Try to determine the report-type by looking at the
- * sub-type of the second body part. */
- $parts = $this->_mimepart->getParts();
- if (!isset($parts[1])) {
- return false;
- }
- $type = $parts[1]->getSubType();
- }
-
- $viewer = Horde_Mime_Viewer::factory($this->_mimepart, 'message/' . Horde_String::lower($type));
- if ($viewer) {
- $viewer->setParams($this->_params);
- }
-
- return $viewer;
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Rfc822 class renders out messages from the
- * message/rfc822 content type.
- *
- * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Rfc822 extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => true,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $this->_mimepart->getContents(),
- 'status' => array(),
- 'type' => 'text/plain; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-
- /**
- * Return the rendered information about the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _renderInfo()
- {
- /* Get the text of the part. Since we need to look for the end of
- * the headers by searching for the CRLFCRLF sequence, use
- * getCanonicalContents() to make sure we are getting the text with
- * CRLF's. */
- $text = $this->_mimepart->getContents(array('canonical' => true));
- if (empty($text)) {
- return array();
- }
-
- /* Search for the end of the header text (CRLFCRLF). */
- $text = substr($text, 0, strpos($text, "\r\n\r\n"));
-
- /* Get the list of headers now. */
- $headers = Horde_Mime_Headers::parseHeaders($text);
-
- $header_array = array(
- 'date' => _("Date"),
- 'from' => _("From"),
- 'to' => _("To"),
- 'cc' => _("Cc"),
- 'bcc' => _("Bcc"),
- 'reply-to' => _("Reply-To"),
- 'subject' => _("Subject")
- );
- $header_output = array();
-
- foreach ($header_array as $key => $val) {
- $hdr = $headers->getValue($key);
- if (!empty($hdr)) {
- $header_output[] = '<strong>' . $val . ':</strong> ' . htmlspecialchars($hdr);
- }
- }
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => empty($header_output) ? '' : ('<div class="fixed mimeHeaders">' . Horde_Text_Filter::filter(implode("<br />\n", $header_output), 'emails') . '</div>'),
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Richtext class renders out HTML text from
- * text/richtext content tags, (RFC 1896 [7.1.3]).
- *
- * A minimal richtext implementation is one that simply converts "<lt>" to
- * "<", converts CRLFs to SPACE, converts <nl> to a newline according to
- * local newline convention, removes everything between a <comment> command
- * and the next balancing </comment> command, and removes all other
- * formatting commands (all text enclosed in angle brackets).
- *
- * We implement the following tags:
- * <bold>, <italic>, <fixed>, <smaller>, <bigger>, <underline>, <center>,
- * <flushleft>, <flushright>, <indent>, <subscript>, <excerpt>, <paragraph>,
- * <signature>, <comment>, <no-op>, <lt>, <nl>
- *
- * The following tags are implemented differently than described in the RFC
- * (due to limitations in HTML output):
- * <heading> - Output as centered, bold text.
- * <footing> - Output as centered, bold text.
- * <np> - Output as paragraph break.
- *
- * The following tags are NOT implemented:
- * <indentright>, <outdent>, <outdentright>, <samepage>, <iso-8859-X>,
- * <us-ascii>,
- *
- * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Richtext extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => true,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $this->_toHTML(),
- 'status' => array(),
- 'type' => 'text/html; charset=' . $this->_mimepart->getCharset()
- )
- );
- }
-
- /**
- * Return the rendered inline version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _renderInline()
- {
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => Horde_String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()),
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-
- /**
- * Convert richtext to HTML.
- *
- * @return string The converted HTML string.
- */
- protected function _toHTML()
- {
- $text = trim($this->_mimepart->getContents());
- if ($text == '') {
- return array();
- }
-
- /* We add space at the beginning and end of the string as it will
- * make some regular expression checks later much easier (so we
- * don't have to worry about start/end of line characters). */
- $text = ' ' . $text . ' ';
-
- /* Remove everything between <comment> tags. */
- $text = preg_replace('/<comment.*>.*<\/comment>/Uis', '', $text);
-
- /* Remove any unrecognized tags in the text. We don't need <no-op>
- * in $tags since it doesn't do anything anyway. All <comment> tags
- * have already been removed. */
- $tags = '<bold><italic><fixed><smaller><bigger><underline><center><flushleft><flushright><indent><subscript><excerpt><paragraph><signature><lt><nl>';
- $text = strip_tags($text, $tags);
-
- /* <lt> becomes a '<'. CRLF becomes a SPACE. */
- $text = str_ireplace(array('<lt>', "\r\n"), array('<', ' '), $text);
-
- /* We try to protect against bad stuff here. */
- $text = @htmlspecialchars($text, ENT_QUOTES, $this->_mimepart->getCharset());
-
- /* <nl> becomes a newline (<br />);
- * <np> becomes a paragraph break (<p />). */
- $text = str_ireplace(array('<nl>', '<np>'), array('<br />', '<p />'), $text);
-
- /* Now convert the known tags to html. Try to remove any tag
- * parameters to stop people from trying to pull a fast one. */
- $replace = array(
- '/(?<!<)<bold.*>(.*)<\/bold>/Uis' => '<span style="font-weight: bold">\1</span>',
- '/(?<!<)<italic.*>(.*)<\/italic>/Uis' => '<span style="font-style: italic">\1</span>',
- '/(?<!<)<fixed.*>(.*)<\/fixed>/Uis' => '<font face="fixed">\1</font>',
- '/(?<!<)<smaller.*>(.*)<\/smaller>/Uis' => '<span style="font-size: smaller">\1</span>',
- '/(?<!<)<bigger.*>(.*)<\/bigger>/Uis' => '<span style="font-size: larger">\1</span>',
- '/(?<!<)<underline.*>(.*)<\/underline>/Uis' => '<span style="text-decoration: underline">\1</span>',
- '/(?<!<)<center.*>(.*)<\/center>/Uis' => '<div align="center">\1</div>',
- '/(?<!<)<flushleft.*>(.*)<\/flushleft>/Uis' => '<div align="left">\1</div>',
- '/(?<!<)<flushright.*>(.*)<\/flushright>/Uis' => '<div align="right">\1</div>',
- '/(?<!<)<indent.*>(.*)<\/indent>/Uis' => '<blockquote>\1</blockquote>',
- '/(?<!<)<excerpt.*>(.*)<\/excerpt>/Uis' => '<cite>\1</cite>',
- '/(?<!<)<subscript.*>(.*)<\/subscript>/Uis' => '<sub>\1</sub>',
- '/(?<!<)<superscript.*>(.*)<\/superscript>/Uis' => '<sup>\1</sup>',
- '/(?<!<)<heading.*>(.*)<\/heading>/Uis' => '<br /><div align="center" style="font-weight: bold">\1</div><br />',
- '/(?<!<)<footing.*>(.*)<\/footing>/Uis' => '<br /><div align="center" style="font-weight: bold">\1</div><br />',
- '/(?<!<)<paragraph.*>(.*)<\/paragraph>/Uis' => '<p>\1</p>',
- '/(?<!<)<signature.*>(.*)<\/signature>/Uis' => '<address>\1</address>'
- );
- $text = preg_replace(array_keys($replace), array_values($replace), $text);
-
- /* Now we remove the leading/trailing space we added at the start. */
- $text = substr($text, 1, -1);
-
- /* Wordwrap. */
- $text = str_replace(array("\t", ' ', "\n "), array(' ', ' ', "\n "), $text);
- if ($text[0] == ' ') {
- $text = ' ' . substr($text, 1);
- }
-
- return '<p style="font-size:100%;font-family:Lucida Console,Courier,Courier New;">' . nl2br($text) . '</p>';
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Rpm class renders out lists of files in RPM
- * packages by using the rpm tool to query the package.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Rpm extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => true,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Metadata for the current viewer/data.
- *
- * @var array
- */
- protected $_metadata = array(
- 'compressed' => true,
- 'embedded' => false,
- 'forceinline' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- $ret = $this->_renderInfo();
- if (!empty($ret)) {
- reset($ret);
- $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
- }
- return $ret;
- }
-
- /**
- * Return the rendered information about the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _renderInfo()
- {
- /* Check to make sure the viewer program exists. */
- if (!isset($this->_conf['location']) ||
- !file_exists($this->_conf['location'])) {
- return array();
- }
-
- $data = '';
- $tmp_rpm = Horde::getTempFile('horde_rpm');
-
- file_put_contents($tmp_rpm, $this->_mimepart->getContents());
-
- $fh = popen($this->_conf['location'] . " -qip $tmp_rpm 2>&1", 'r');
- while (($rc = fgets($fh, 8192))) {
- $data .= $rc;
- }
- pclose($fh);
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => '<pre>' . htmlentities($data) . '</pre>',
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Rtf class renders out Rich Text Format documents in
- * HTML format by using the UnRTF package.
- *
- * UnRTF package: http://www.gnu.org/software/unrtf/unrtf.html
- *
- * Copyright 2007 Duck <duck@obala.net>
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Duck <duck@obala.net>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Rtf extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- /* Check to make sure the viewer program exists. */
- if (!isset($this->_conf['location']) ||
- !file_exists($this->_conf['location'])) {
- return array();
- }
-
- $tmp_rtf = Horde::getTempFile('rtf');
- $tmp_output = Horde::getTempFile('rtf');
-
- file_put_contents($tmp_rtf, $this->_mimepart->getContents());
-
- exec($this->_conf['location'] . " $tmp_rtf > $tmp_output");
-
- if (file_exists($tmp_output)) {
- $data = file_get_contents($tmp_output);
- } else {
- $data = _("Unable to translate this RTF document");
- }
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $data,
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Security class is a wrapper used to load the
- * appropriate Horde_Mime_Viewer for secure multipart messages (defined by RFC
- * 1847). This class handles multipart/signed and multipart/encrypted data.
- *
- * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Security extends Horde_Mime_Viewer_Driver
-{
- /**
- * Return the underlying MIME Viewer for this part.
- *
- * @return mixed A Horde_Mime_Viewer object, or false if not found.
- */
- protected function _getViewer()
- {
- if (!($protocol = $this->_mimepart->getContentTypeParameter('protocol'))) {
- return false;
- }
-
- $viewer = Horde_Mime_Viewer::factory($this->_mimepart, $protocol);
- if ($viewer) {
- $viewer->setParams($this->_params);
- }
- return $viewer;
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Simple class renders out plain text without any
- * modifications.
- *
- * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Simple extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $this->_mimepart->getContents(),
- 'status' => array(),
- 'type' => 'text/plain; charset=' . $this->_mimepart->getCharset()
- )
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Smil renders SMIL documents to very basic HTML.
- *
- * Copyright 2006-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Jan Schneider <jan@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Smil extends Horde_Mime_Viewer_Driver
-{
- /**
- * Handle for the XML parser object.
- *
- * @var resource
- */
- protected $_parser;
-
- /**
- * String buffer to hold the generated content
- *
- * @var string
- */
- protected $_content;
-
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Metadata for the current viewer/data.
- *
- * @var array
- */
- protected $_metadata = array(
- 'compressed' => false,
- 'embedded' => false,
- 'forceinline' => true
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- $this->_content = '';
-
- /* Create a new parser and set its default properties. */
- $this->_parser = xml_parser_create();
- xml_set_object($this->_parser, $this);
- xml_set_element_handler($this->_parser, '_startElement', '_endElement');
- xml_set_character_data_handler($this->_parser, '_defaultHandler');
- xml_parse($this->_parser, $this->_mimepart->getContents(), true);
- xml_parser_free($this->_parser);
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $this->_content,
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-
- /**
- * User-defined function callback for start elements.
- *
- * @param object $parser Handle to the parser instance.
- * @param string $name The name of this XML element.
- * @param array $attrs List of this element's attributes.
- */
- protected function _startElement($parser, $name, $attrs)
- {
- switch ($name) {
- case 'IMG':
- if (isset($attrs['SRC'])) {
- $this->_content .= '<img src="' . htmlspecialchars($attrs['SRC']) . '" />';
- }
- break;
- }
- }
-
- /**
- * User-defined function callback for end elements.
- *
- * @param object $parser Handle to the parser instance.
- * @param string $name The name of this XML element.
- */
- protected function _endElement($parser, $name)
- {
- }
-
- /**
- * User-defined function callback for character data.
- *
- * @param object $parser Handle to the parser instance.
- * @param string $data String of character data.
- */
- protected function _defaultHandler($parser, $data)
- {
- $data = trim($data);
- if (!empty($data)) {
- $this->_content .= ' ' . htmlspecialchars($data);
- }
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Source class is a class for any viewer that wants
- * to provide line numbers to extend.
- *
- * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Source extends Horde_Mime_Viewer_Driver
-{
- /**
- * Add line numbers to a block of code.
- *
- * @param string $code The code to number.
- *
- * @return string The code with line numbers added.
- */
- protected function _lineNumber($code, $linebreak = "\n")
- {
- $html = array('<table class="lineNumbered" cellspacing="0"><tr><th>');
- for ($l = 1, $lines = substr_count($code, $linebreak) + 1; $l <= $lines; ++$l) {
- $html[] = sprintf('<a id="l%s" href="#l%s">%s</a><br />', $l, $l, $l);
- }
- return implode("\n", $html) . '</th><td><div>' . $code . '</div></td></tr></table>';
- }
-
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Srchighlite class renders out various content in HTML
- * format by using the GNU source-highlight package.
- *
- * Source-highlight: http://www.gnu.org/software/src-highlite/
- * Tested with v3.1.3
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Mike Cochrane <mike@graftonhall.co.nz>
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Srchighlite extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- $ret = $this->_renderInline();
-
- reset($ret);
- $ret[key($ret)]['data'] = '<html><body>' .
- $ret[key($ret)]['data'] .
- '</body></html>';
-
- return $ret;
- }
-
- /**
- * Return the rendered inline version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _renderInline()
- {
- /* Check to make sure the viewer program exists. */
- if (!isset($this->_conf['location']) ||
- !file_exists($this->_conf['location'])) {
- return array();
- }
-
- /* Create temporary files for Webcpp. */
- $tmpin = Horde::getTempFile('SrcIn');
- $tmpout = Horde::getTempFile('SrcOut', false);
-
- /* Write the contents of our buffer to the temporary input file. */
- file_put_contents($tmpin, $this->_mimepart->getContents());
-
- /* Determine the language from the mime type. */
- $lang = $this->_typeToLang($this->_mimepart->getType());
-
- /* Execute Source-Highlite. */
- exec($this->_conf['location'] . " --src-lang $lang --out-format html --input $tmpin --output $tmpout");
- $results = file_get_contents($tmpout);
- unlink($tmpout);
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $results,
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-
- /**
- * Attempts to determine what mode to use for the source-highlight
- * program from a MIME type.
- *
- * @param string $type The MIME type.
- *
- * @return string The mode to use.
- */
- protected function _typeToLang($type)
- {
- switch ($type) {
- case 'application/x-javascript':
- return 'js';
-
- case 'application/x-perl':
- return 'perl';
-
- case 'application/x-php':
- case 'x-extension/phps':
- case 'x-extension/php3s':
- case 'application/x-httpd-php':
- case 'application/x-httpd-php3':
- case 'application/x-httpd-phps':
- return 'php';
-
- case 'application/x-python':
- return 'python';
-
- case 'application/x-ruby':
- return 'ruby';
-
- case 'application/x-sh':
- case 'application/x-shellscript':
- return 'sh';
-
- case 'application/x-tcl':
- return 'tcl';
-
- case 'application/xml':
- case 'text/xml':
- return 'xml';
-
- case 'text/cpp':
- case 'text/x-c++src':
- case 'text/x-c++hdr':
- return 'cpp';
-
- case 'text/css':
- case 'x-extension/css':
- return 'css';
-
- case 'text/diff':
- case 'text/x-diff':
- case 'text/x-patch':
- return 'diff';
-
- case 'text/x-chdr':
- case 'text/x-csrc':
- return 'c';
-
- case 'text/x-emacs-lisp':
- return 'lisp';
-
- case 'text/x-fortran':
- case 'x-extension/f77':
- case 'x-extension/f90':
- case 'x-extension/for':
- case 'x-extension/ftn':
- return 'fortran';
-
- case 'text/x-java':
- return 'java';
-
- case 'text/x-pascal':
- return 'pascal';
-
- case 'text/x-sql':
- return 'sql';
-
- case 'text/x-tex':
- return 'tex';
-
- case 'x-extension/asm':
- return 'asm';
-
- case 'x-extension/bat':
- return 'batch';
-
- case 'x-extension/cs':
- return 'csharp';
-
- case 'x-extension/vb':
- case 'x-extension/vba':
- return 'vbs';
- }
- }
-
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Tgz class renders out plain or gzipped tarballs in
- * HTML.
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Anil Madhavapeddy <anil@recoil.org>
- * @author Michael Cochrane <mike@graftonhall.co.nz>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => true,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * The list of compressed subtypes.
- *
- * @var array
- */
- protected $_gzipSubtypes = array(
- 'x-compressed-tar', 'tgz', 'x-tgz', 'gzip', 'x-gzip',
- 'x-gzip-compressed', 'x-gtar'
- );
-
- /**
- * Constructor.
- *
- * @param Horde_Mime_Part $mime_part Reference to an object with the
- * information to be rendered.
- * @param array $conf Configuration specific to the
- * driver.
- */
- public function __construct($mime_part, $conf = array())
- {
- parent::__construct($mime_part, $conf);
-
- $this->_metadata['compressed'] = in_array($mime_part->getSubType(), $this->_gzipSubtypes);
- }
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _render()
- {
- $ret = $this->_renderInfo();
- if (!empty($ret)) {
- reset($ret);
- $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] .
- '</body></html>';
- }
- return $ret;
- }
-
- /**
- * Return the rendered information about the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _renderInfo()
- {
- /* Currently, can't do anything without tar file. */
- $subtype = $this->_mimepart->getSubType();
- if (in_array($subtype, array('gzip', 'x-gzip', 'x-gzip-compressed'))) {
- return array();
- }
-
- $contents = $this->_mimepart->getContents();
-
- /* Decompress gzipped files. */
- if (in_array($subtype, $this->_gzipSubtypes)) {
- $gzip = Horde_Compress::factory('gzip');
- $contents = $gzip->decompress($contents);
- }
-
- /* Obtain the list of files/data in the tar file. */
- $tar = Horde_Compress::factory('tar');
- $tarData = $tar->decompress($contents);
-
- $charset = $GLOBALS['registry']->getCharset();
- $fileCount = count($tarData);
-
- $name = $this->_mimepart->getName(true);
- if (empty($name)) {
- $name = _("unnamed");
- }
-
- $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
- '<table><tr><td align="left"><pre>' .
- Horde_Text_Filter::filter(_("Archive Name") . ': ' . $name, 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
- Horde_Text_Filter::filter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
- Horde_Text_Filter::filter(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) .
- "\n\n" .
- Horde_Text_Filter::filter(
- str_pad(_("File Name"), 62, ' ', STR_PAD_RIGHT) .
- str_pad(_("Attributes"), 15, ' ', STR_PAD_LEFT) .
- str_pad(_("Size"), 10, ' ', STR_PAD_LEFT) .
- str_pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT),
- 'space2html',
- array('charset' => $charset, 'encode' => true, 'encode_all' => true)
- ) . "\n" .
- str_repeat('-', 106) . "\n";
-
- foreach ($tarData as $val) {
- $text .= Horde_Text_Filter::filter(
- str_pad($val['name'], 62, ' ', STR_PAD_RIGHT) .
- str_pad($val['attr'], 15, ' ', STR_PAD_LEFT) .
- str_pad($val['size'], 10, ' ', STR_PAD_LEFT) .
- str_pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT),
- 'space2html',
- array('charset' => $charset, 'encode' => true, 'encode_all' => true)
- ) . "\n";
- }
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => nl2br($text . str_repeat('-', 106) . "\n</pre></td></tr></table>"),
- 'status' => array(),
- 'type' => 'text/html; charset=' . $charset
- )
- );
- }
-
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Tnef class allows MS-TNEF attachments to be
- * displayed.
- *
- * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Jan Schneider <jan@horde.org>
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => true,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Metadata for the current viewer/data.
- *
- * @var array
- */
- protected $_metadata = array(
- 'compressed' => true,
- 'embedded' => false,
- 'forceinline' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _render()
- {
- $ret = $this->_renderInfo();
- if (!empty($ret)) {
- reset($ret);
- $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
- }
- return $ret;
- }
-
- /**
- * Return the rendered information about the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _renderInfo()
- {
- $tnef = Horde_Compress::factory('tnef');
- $info = $tnef->decompress($this->_mimepart->getContents());
-
- $data = '<table border="1">';
- if (empty($info)) {
- $data .= '<tr><td>' . _("MS-TNEF Attachment contained no data.") . '</td></tr>';
- } else {
- $data .= '<tr><td>' . _("Name") . '</td><td>' . _("Mime Type") . '</td></tr>';
- foreach ($info as $part) {
- $data .= '<tr><td>' . $part['name'] . '</td><td>' . $part['type'] . '/' . $part['subtype'] . '</td></tr>';
- }
- }
- $data .= '</table>';
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $data,
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Vcard class renders out vCards in HTML format.
- *
- * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Jan Schneider <jan@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => true,
- 'raw' => false
- );
-
- /**
- * URL that can be used as a callback for displaying images.
- *
- * @var Horde_Url
- */
- protected $_imageUrl;
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- $ret = $this->_renderInline();
-
- if (!empty($ret)) {
- reset($ret);
- Horde::startBuffer();
- include $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc';
- echo $ret[key($ret)]['data'];
- include $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
- $ret[key($ret)]['data'] = Horde::endBuffer();
- }
-
- return $ret;
- }
-
- /**
- * Return the rendered inline version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _renderInline()
- {
- global $registry, $prefs, $notification;
-
- $app = false;
- $data = $this->_mimepart->getContents();
- $html = '';
- $import_msg = null;
- $title = _("vCard");
-
- $iCal = new Horde_iCalendar();
- if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
- $notification->push(_("There was an error reading the contact data."), 'horde.error');
- }
-
- if (Horde_Util::getFormData('import') &&
- Horde_Util::getFormData('source') &&
- $registry->hasMethod('contacts/import')) {
- $source = Horde_Util::getFormData('source');
- $count = 0;
- foreach ($iCal->getComponents() as $c) {
- if ($c instanceof Horde_iCalendar_vcard) {
- try {
- $contacts = $registry->call('contacts/import', array($c, null, $source));
- ++$count;
- } catch (Horde_Exception $e) {
- $notification->push(_("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
- }
- }
- }
- $notification->push(sprintf(ngettext(
- "%d contact was successfully added to your address book.",
- "%d contacts were successfully added to your address book.",
- $count),
- $count),
- 'horde.success');
- }
-
- $html .= '<table cellspacing="1" border="0" cellpadding="1">';
-
- foreach ($iCal->getComponents() as $i => $vc) {
- if ($i > 0) {
- $html .= '<tr><td colspan="2"> </td></tr>';
- }
-
- $html .= '<tr><td colspan="2" class="header">';
- $fullname = $vc->getAttributeDefault('FN', false);
- if ($fullname !== false) {
- $html .= $fullname;
- }
- $html .= '</td></tr>';
-
- $n = $vc->printableName();
- if (!empty($n)) {
- $html .= $this->_row(_("Name"), $n);
- }
-
- $aliases = $vc->getAttributeValues('ALIAS');
- if (!is_a($aliases, 'PEAR_Error')) {
- $html .= $this->_row(_("Alias"), implode("\n", $aliases));
- }
- $birthdays = $vc->getAttributeValues('BDAY');
- if (!is_a($birthdays, 'PEAR_Error')) {
- $birthday = new Horde_Date($birthdays[0]);
- $html .= $this->_row(
- _("Birthday"),
- $birthday->strftime($prefs->getValue('date_format')));
- }
-
- $photos = $vc->getAllAttributes('PHOTO');
- foreach ($photos as $p => $photo) {
- if (isset($photo['params']['VALUE']) &&
- Horde_String::upper($photo['params']['VALUE']) == 'URI') {
- $html .= $this->_row(_("Photo"),
- '<img src="' . htmlspecialchars($photo['value']) . '" />',
- false);
- } elseif (isset($photo['params']['ENCODING']) &&
- Horde_String::upper($photo['params']['ENCODING']) == 'B' &&
- isset($photo['params']['TYPE'])) {
- if ($GLOBALS['browser']->hasFeature('datauri') === true ||
- $GLOBALS['browser']->hasFeature('datauri') >= strlen($photo['value'])) {
- $html .= $this->_row(_("Photo"),
- '<img src="data:' . htmlspecialchars($photo['params']['TYPE'] . ';base64,' . $photo['value']) . '" />',
- false);
- } elseif ($this->_imageUrl) {
- $html .= $this->_row(_("Photo"),
- '<img src="' . htmlspecialchars($this->_imageUrl->add(array('c' => $i, 'p' => $p))) . '" />',
- false);
- }
- }
- }
-
- $labels = $vc->getAllAttributes('LABEL');
- foreach ($labels as $label) {
- if (isset($label['params']['TYPE'])) {
- if (!is_array($label['params']['TYPE'])) {
- $label['params']['TYPE'] = array($label['params']['TYPE']);
- }
- } else {
- $label['params']['TYPE'] = array_keys($label['params']);
- }
- $types = array();
- foreach ($label['params']['TYPE'] as $type) {
- switch(Horde_String::upper($type)) {
- case 'HOME':
- $types[] = _("Home Address");
- break;
-
- case 'WORK':
- $types[] = _("Work Address");
- break;
-
- case 'DOM':
- $types[] = _("Domestic Address");
- break;
-
- case 'INTL':
- $types[] = _("International Address");
- break;
-
- case 'POSTAL':
- $types[] = _("Postal Address");
- break;
-
- case 'PARCEL':
- $types[] = _("Parcel Address");
- break;
-
- case 'PREF':
- $types[] = _("Preferred Address");
- break;
- }
- }
- if (!count($types)) {
- $types = array(_("Address"));
- }
- $html .= $this->_row(implode('/', $types), $label['value']);
- }
-
- $adrs = $vc->getAllAttributes('ADR');
- foreach ($adrs as $item) {
- if (isset($item['params']['TYPE'])) {
- if (!is_array($item['params']['TYPE'])) {
- $item['params']['TYPE'] = array($item['params']['TYPE']);
- }
- } else {
- $item['params']['TYPE'] = array_keys($item['params']);
- }
- $address = $item['values'];
- $a = array();
- if (isset($address[VCARD_ADR_STREET])) {
- $a[] = $address[VCARD_ADR_STREET];
- }
- if (isset($address[VCARD_ADR_LOCALITY])) {
- $a[] = $address[VCARD_ADR_LOCALITY];
- }
- if (isset($address[VCARD_ADR_REGION])) {
- $a[] = $address[VCARD_ADR_REGION];
- }
- if (isset($address[VCARD_ADR_POSTCODE])) {
- $a[] = $address[VCARD_ADR_POSTCODE];
- }
- if (isset($address[VCARD_ADR_COUNTRY])) {
- $a[] = $address[VCARD_ADR_COUNTRY];
- }
- $types = array();
- foreach ($item['params']['TYPE'] as $type) {
- switch(Horde_String::upper($type)) {
- case 'HOME':
- $types[] = _("Home Address");
- break;
-
- case 'WORK':
- $types[] = _("Work Address");
- break;
-
- case 'DOM':
- $types[] = _("Domestic Address");
- break;
-
- case 'INTL':
- $types[] = _("International Address");
- break;
-
- case 'POSTAL':
- $types[] = _("Postal Address");
- break;
-
- case 'PARCEL':
- $types[] = _("Parcel Address");
- break;
-
- case 'PREF':
- $types[] = _("Preferred Address");
- break;
- }
- }
- if (!count($types)) {
- $types = array(_("Address"));
- }
- $html .= $this->_row(implode('/', $types), implode("\n", $a));
- }
-
- $numbers = $vc->getAllAttributes('TEL');
-
- foreach ($numbers as $number) {
- if (isset($number['params']['TYPE'])) {
- if (!is_array($number['params']['TYPE'])) {
- $number['params']['TYPE'] = array($number['params']['TYPE']);
- }
- foreach ($number['params']['TYPE'] as $type) {
- $number['params'][Horde_String::upper($type)] = true;
- }
- }
- if (isset($number['params']['FAX'])) {
- $html .= $this->_row(_("Fax"), $number['value']);
- } else {
- if (isset($number['params']['HOME'])) {
- $html .= $this->_row(_("Home Phone"),
- $number['value']);
- } elseif (isset($number['params']['WORK'])) {
- $html .= $this->_row(_("Work Phone"),
- $number['value']);
- } elseif (isset($number['params']['CELL'])) {
- $html .= $this->_row(_("Cell Phone"),
- $number['value']);
- } else {
- $html .= $this->_row(_("Phone"),
- $number['value']);
- }
- }
- }
-
- $addresses = $vc->getAllAttributes('EMAIL');
- $emails = array();
- foreach ($addresses as $address) {
- if (isset($address['params']['TYPE'])) {
- if (!is_array($address['params']['TYPE'])) {
- $address['params']['TYPE'] = array($address['params']['TYPE']);
- }
- foreach ($address['params']['TYPE'] as $type) {
- $address['params'][Horde_String::upper($type)] = true;
- }
- }
- $email = '<a href="';
- if ($registry->hasMethod('mail/compose')) {
- $email .= $registry->call(
- 'mail/compose',
- array(array('to' => $address['value'])));
- } else {
- $email .= 'mailto:' . htmlspecialchars($address['value']);
- }
- $email .= '">' . htmlspecialchars($address['value']) . '</a>';
- if (isset($address['params']['PREF'])) {
- array_unshift($emails, $email);
- } else {
- $emails[] = $email;
- }
- }
-
- if (count($emails)) {
- $html .= $this->_row(_("Email"), implode("\n", $emails), false);
- }
-
- $title = $vc->getAttributeValues('TITLE');
- if (!is_a($title, 'PEAR_Error')) {
- $html .= $this->_row(_("Title"), $title[0]);
- }
-
- $role = $vc->getAttributeValues('ROLE');
- if (!is_a($role, 'PEAR_Error')) {
- $html .= $this->_row(_("Role"), $role[0]);
- }
-
- $org = $vc->getAttributeValues('ORG');
- if (!is_a($org, 'PEAR_Error')) {
- $html .= $this->_row(_("Company"), $org[0]);
- if (isset($org[1])) {
- $html .= $this->_row(_("Department"), $org[1]);
- }
- }
-
- $notes = $vc->getAttributeValues('NOTE');
- if (!is_a($notes, 'PEAR_Error')) {
- $html .= $this->_row(_("Notes"), $notes[0]);
- }
-
- $url = $vc->getAttributeValues('URL');
- if (!is_a($url, 'PEAR_Error')) {
- $html .= $this->_row(
- _("URL"),
- '<a href="' . htmlspecialchars($url[0])
- . '" target="_blank">' . htmlspecialchars($url[0])
- . '</a>',
- false);
- }
- }
-
- if ($registry->hasMethod('contacts/import') &&
- $registry->hasMethod('contacts/sources')) {
- $html .= '<tr><td colspan="2" class="smallheader"><form action="'
- . Horde::selfUrl() . '" method="get" name="vcard_import">'
- . Horde_Util::formInput();
- foreach ($_GET as $key => $val) {
- $html .= '<input type="hidden" name="' . htmlspecialchars($key)
- . '" value="' . htmlspecialchars($val) . '" />';
- }
-
- $sources = $registry->call('contacts/sources', array(true));
- if (count($sources) > 1) {
- $html .=
- '<input type="submit" class="button" name="import" value="'
- . _("Add to address book:") . '" />'
- . '<label for="add_source" class="hidden">'
- . _("Address Book") . '</label>'
- . '<select id="add_source" name="source">';
- foreach ($sources as $key => $label) {
- $selected = ($key == $prefs->getValue('add_source'))
- ? ' selected="selected"' : '';
- $html .= '<option value="' . htmlspecialchars($key) . '"'
- . $selected . '>' . htmlspecialchars($label)
- . '</option>';
- }
- } else {
- reset($sources);
- $html .=
- '<input type="submit" class="button" name="import" value="'
- . _("Add to my address book") . '" />'
- . '<input type="hidden" name="source" value="'
- . htmlspecialchars(key($sources)) . '" />';
- }
-
- $html .= '</form></td></tr><tr><td> </td></tr>';
- }
-
- $html .= '</table>';
-
- Horde::startBuffer();
- $notification->notify(array('listeners' => 'status'));
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => Horde::endBuffer() . $html,
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-
- /**
- * TODO
- */
- protected function _row($label, $value, $encode = true)
- {
- if ($encode) {
- $label = htmlspecialchars($label);
- $value = htmlspecialchars($value);
- }
- return '<tr><td class="item" valign="top">' . $label .
- '</td><td class="item" valign="top">' . nl2br($value) .
- "</td></tr>\n";
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Wordperfect class renders out WordPerfect documents
- * in HTML format by using the libwpd package.
- *
- * libpwd website: http://libwpd.sourceforge.net/
- *
- * Copyright 2007-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Matt Selsky <selsky@columbia.edu>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Wordperfect extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => false,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- */
- protected function _render()
- {
- /* Check to make sure the viewer program exists. */
- if (!isset($this->_conf['location']) ||
- !file_exists($this->_conf['location'])) {
- return array();
- }
-
- $tmp_wpd = Horde::getTempFile('wpd');
- $tmp_output = Horde::getTempFile('wpd');
-
- file_put_contents($tmp_wpd, $this->_mimepart->getContents());
-
- exec($this->_conf['location'] . " $tmp_wpd > $tmp_output");
-
- if (file_exists($tmp_output)) {
- $data = file_get_contents($tmp_output);
- } else {
- $data = _("Unable to translate this WordPerfect document");
- }
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => $data,
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-}
+++ /dev/null
-<?php
-/**
- * The Horde_Mime_Viewer_Zip class renders out the contents of ZIP files in
- * HTML format.
- *
- * Copyright 2000-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Chuck Hagenbuch <chuck@horde.org>
- * @author Michael Cochrane <mike@graftonhall.co.nz>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Mime
- */
-class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Driver
-{
- /**
- * This driver's display capabilities.
- *
- * @var array
- */
- protected $_capability = array(
- 'full' => true,
- 'info' => true,
- 'inline' => false,
- 'raw' => false
- );
-
- /**
- * Metadata for the current viewer/data.
- *
- * @var array
- */
- protected $_metadata = array(
- 'compressed' => true,
- 'embedded' => false,
- 'forceinline' => false
- );
-
- /**
- * A callback function to use in _toHTML().
- *
- * @var callback
- */
- protected $_callback = null;
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _render()
- {
- $ret = $this->_toHTML();
- if (!empty($ret)) {
- reset($ret);
- $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
- }
- return $ret;
- }
-
- /**
- * Return the rendered information about the Horde_Mime_Part object.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _renderInfo()
- {
- return $this->_toHTML();
- }
-
- /**
- * Converts the ZIP file to an HTML display.
- *
- * @return array See Horde_Mime_Viewer_Driver::render().
- * @throws Horde_Exception
- */
- protected function _toHTML()
- {
- $contents = $this->_mimepart->getContents();
-
- $zip = Horde_Compress::factory('zip');
- $zipInfo = $zip->decompress($contents, array('action' => Horde_Compress_Zip::ZIP_LIST));
-
- $fileCount = count($zipInfo);
-
- /* Determine maximum file name length. */
- $max_array = array();
- foreach ($zipInfo as $val) {
- $max_array[] = strlen($val['name']);
- }
- $maxlen = empty($max_array) ? 0 : max($max_array);
-
- $name = $this->_mimepart->getName(true);
- if (empty($name)) {
- $name = _("unnamed");
- }
-
- $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
- '<table><tr><td align="left"><span style="font-family:monospace">' .
- Horde_Text_Filter::filter(
- _("Archive Name") . ': ' . $name . "\n" .
- _("Archive File Size") . ': ' . strlen($contents) .
- " bytes\n" .
- sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount) .
- "\n\n" .
- Horde_String::pad(_("File Name"), $maxlen, ' ', STR_PAD_RIGHT) .
- Horde_String::pad(_("Attributes"), 10, ' ', STR_PAD_LEFT) .
- Horde_String::pad(_("Size"), 10, ' ', STR_PAD_LEFT) .
- Horde_String::pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) .
- Horde_String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) .
- Horde_String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT) .
- "\n",
- 'space2html',
- array('charset' => $GLOBALS['registry']->getCharset(), 'encode' => true, 'encode_all' => true)
- ) . str_repeat('-', 59 + $maxlen) . "\n";
-
- foreach ($zipInfo as $key => $val) {
- $ratio = (empty($val['size']))
- ? 0
- : 100 * ($val['csize'] / $val['size']);
-
- $val['name'] = Horde_String::pad($val['name'], $maxlen, ' ', STR_PAD_RIGHT);
- $val['attr'] = Horde_String::pad($val['attr'], 10, ' ', STR_PAD_LEFT);
- $val['size'] = Horde_String::pad($val['size'], 10, ' ', STR_PAD_LEFT);
- $val['date'] = Horde_String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT);
- $val['method'] = Horde_String::pad($val['method'], 10, ' ', STR_PAD_LEFT);
- $val['ratio'] = Horde_String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT);
-
- reset($val);
- while (list($k, $v) = each($val)) {
- $val[$k] = Horde_Text_Filter::filter($v, 'space2html', array('charset' => $GLOBALS['registry']->getCharset(), 'encode' => true, 'encode_all' => true));
- }
-
- if (!is_null($this->_callback)) {
- $val = call_user_func($this->_callback, $key, $val);
- }
-
- $text .= $val['name'] . $val['attr'] . $val['size'] .
- $val['date'] . $val['method'] . $val['ratio'] .
- "\n";
- }
-
- return array(
- $this->_mimepart->getMimeId() => array(
- 'data' => nl2br($text . str_repeat('-', 59 + $maxlen) . "\n</span></td></tr></table>"),
- 'status' => array(),
- 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
- )
- );
- }
-}
<name>Mime</name>
<channel>pear.horde.org</channel>
<summary>Horde MIME Library</summary>
- <description>The Horde_Mime:: class provides methods for dealing with MIME (RFC 2045) and related e-mail (RFC 822/2822/5322) standards.
+ <description>Provides methods for dealing with MIME (RFC 2045) and related e-mail (RFC 822/2822/5322) standards.
</description>
<lead>
<name>Chuck Hagenbuch</name>
<api>alpha</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Removed Webcpp and Enscript viewers. Source code highlighting is now
+ <notes>* Moved viewer code to horde/Mime_Viewer package.
+ * Removed Webcpp and Enscript viewers. Source code highlighting is now
exclusively handled by the Srchighlight driver.
* No need to generate Content-Transfer-Encoding header if part data is 7bit.
* Default disposition should be empty by default, not inline (RFC 2183 [2]).
<dir name="lib">
<dir name="Horde">
<dir name="Mime">
- <dir name="Viewer">
- <dir name="Ooo">
- <file name="common.xsl" role="php" />
- <file name="global_document.xsl" role="php" />
- <file name="main_html.xsl" role="php" />
- <file name="palm.xsl" role="php" />
- <file name="style_header.xsl" role="php" />
- <file name="style_inlined.xsl" role="php" />
- <file name="style_mapping.xsl" role="php" />
- <file name="table.xsl" role="php" />
- <file name="table_cells.xsl" role="php" />
- <file name="table_columns.xsl" role="php" />
- <file name="table_rows.xsl" role="php" />
- </dir> <!-- /lib/Horde/Mime/Viewer/Ooo -->
- <file name="Audio.php" role="php" />
- <file name="Css.php" role="php" />
- <file name="Deb.php" role="php" />
- <file name="Default.php" role="php" />
- <file name="Driver.php" role="php" />
- <file name="Enriched.php" role="php" />
- <file name="Html.php" role="php" />
- <file name="Images.php" role="php" />
- <file name="Msexcel.php" role="php" />
- <file name="Mspowerpoint.php" role="php" />
- <file name="Msword.php" role="php" />
- <file name="Ooo.php" role="php" />
- <file name="Pdf.php" role="php" />
- <file name="Php.php" role="php" />
- <file name="Plain.php" role="php" />
- <file name="Rar.php" role="php" />
- <file name="Report.php" role="php" />
- <file name="Rfc822.php" role="php" />
- <file name="Richtext.php" role="php" />
- <file name="Rpm.php" role="php" />
- <file name="Rtf.php" role="php" />
- <file name="Security.php" role="php" />
- <file name="Simple.php" role="php" />
- <file name="Smil.php" role="php" />
- <file name="Source.php" role="php" />
- <file name="Srchighlite.php" role="php" />
- <file name="Tgz.php" role="php" />
- <file name="Tnef.php" role="php" />
- <file name="Vcard.php" role="php" />
- <file name="Wordperfect.php" role="php" />
- <file name="Zip.php" role="php" />
- </dir> <!-- /lib/Horde/Mime/Viewer -->
<file name="Address.php" role="php" />
<file name="Exception.php" role="php" />
<file name="Headers.php" role="php" />
<file name="Mail.php" role="php" />
<file name="Mdn.php" role="php" />
<file name="Part.php" role="php" />
- <file name="Viewer.php" role="php" />
<file name="mime.mapping.php" role="php" />
</dir> <!-- /lib/Horde/Mime -->
<file name="Mime.php" role="php" />
<file name="attachment.bin" role="test" />
<file name="bug_325.txt" role="test" />
<file name="sample_msg.txt" role="test" />
- <file name="url1.html" role="test" />
- <file name="url2.html" role="test" />
- <file name="url3.html" role="test" />
- <file name="url4.html" role="test" />
- <file name="url5.html" role="test" />
- <file name="url6.html" role="test" />
- <file name="url7.html" role="test" />
</dir> <!-- /test/Horde/Mime/fixtures -->
<file name="AllTests.php" role="test" />
<file name="bug_325.phpt" role="test" />
<file name="parse_002.phpt" role="test" />
<file name="parse_003.phpt" role="test" />
<file name="rfc2231.phpt" role="test" />
- <file name="url.phpt" role="test" />
- <file name="viewer_php.phpt" role="test" />
</dir> <!-- /test/Horde/Mime -->
</dir> <!-- /test/Horde -->
</dir> <!-- /test -->
<min>1.5.4</min>
</pearinstaller>
<package>
- <name>Core</name>
- <channel>pear.horde.org</channel>
- </package>
- <package>
<name>Exception</name>
<channel>pear.horde.org</channel>
</package>
<channel>pecl.php.net</channel>
</package>
<package>
- <name>Browser</name>
- <channel>pear.horde.org</channel>
- </package>
- <package>
- <name>Compress</name>
- <channel>pear.horde.org</channel>
- </package>
- <package>
- <name>iCalendar</name>
- <channel>pear.horde.org</channel>
- </package>
- <package>
<name>Net_SMTP</name>
<channel>pear.php.net</channel>
<min>1.3.0</min>
</package>
<package>
- <name>Prefs</name>
- <channel>pear.horde.org</channel>
- </package>
- <package>
<name>Text_Filter</name>
<channel>pear.horde.org</channel>
</package>
</dependencies>
<phprelease>
<filelist>
- <install name="lib/Horde/Mime/Viewer/Ooo/common.xsl" as="Horde/Mime/Viewer/Ooo/common.xsl" />
- <install name="lib/Horde/Mime/Viewer/Ooo/global_document.xsl" as="Horde/Mime/Viewer/Ooo/global_document.xsl" />
- <install name="lib/Horde/Mime/Viewer/Ooo/main_html.xsl" as="Horde/Mime/Viewer/Ooo/main_html.xsl" />
- <install name="lib/Horde/Mime/Viewer/Ooo/palm.xsl" as="Horde/Mime/Viewer/Ooo/palm.xsl" />
- <install name="lib/Horde/Mime/Viewer/Ooo/style_header.xsl" as="Horde/Mime/Viewer/Ooo/style_header.xsl" />
- <install name="lib/Horde/Mime/Viewer/Ooo/style_inlined.xsl" as="Horde/Mime/Viewer/Ooo/style_inlined.xsl" />
- <install name="lib/Horde/Mime/Viewer/Ooo/style_mapping.xsl" as="Horde/Mime/Viewer/Ooo/style_mapping.xsl" />
- <install name="lib/Horde/Mime/Viewer/Ooo/table.xsl" as="Horde/Mime/Viewer/Ooo/table.xsl" />
- <install name="lib/Horde/Mime/Viewer/Ooo/table_cells.xsl" as="Horde/Mime/Viewer/Ooo/table_cells.xsl" />
- <install name="lib/Horde/Mime/Viewer/Ooo/table_columns.xsl" as="Horde/Mime/Viewer/Ooo/table_columns.xsl" />
- <install name="lib/Horde/Mime/Viewer/Ooo/table_rows.xsl" as="Horde/Mime/Viewer/Ooo/table_rows.xsl" />
- <install name="lib/Horde/Mime/Viewer/Audio.php" as="Horde/Mime/Viewer/Audio.php" />
- <install name="lib/Horde/Mime/Viewer/Css.php" as="Horde/Mime/Viewer/Css.php" />
- <install name="lib/Horde/Mime/Viewer/Deb.php" as="Horde/Mime/Viewer/Deb.php" />
- <install name="lib/Horde/Mime/Viewer/Default.php" as="Horde/Mime/Viewer/Default.php" />
- <install name="lib/Horde/Mime/Viewer/Driver.php" as="Horde/Mime/Viewer/Driver.php" />
- <install name="lib/Horde/Mime/Viewer/Enriched.php" as="Horde/Mime/Viewer/Enriched.php" />
- <install name="lib/Horde/Mime/Viewer/Html.php" as="Horde/Mime/Viewer/Html.php" />
- <install name="lib/Horde/Mime/Viewer/Images.php" as="Horde/Mime/Viewer/Images.php" />
- <install name="lib/Horde/Mime/Viewer/Msexcel.php" as="Horde/Mime/Viewer/Msexcel.php" />
- <install name="lib/Horde/Mime/Viewer/Mspowerpoint.php" as="Horde/Mime/Viewer/Mspowerpoint.php" />
- <install name="lib/Horde/Mime/Viewer/Msword.php" as="Horde/Mime/Viewer/Msword.php" />
- <install name="lib/Horde/Mime/Viewer/Ooo.php" as="Horde/Mime/Viewer/Ooo.php" />
- <install name="lib/Horde/Mime/Viewer/Pdf.php" as="Horde/Mime/Viewer/Pdf.php" />
- <install name="lib/Horde/Mime/Viewer/Php.php" as="Horde/Mime/Viewer/Php.php" />
- <install name="lib/Horde/Mime/Viewer/Plain.php" as="Horde/Mime/Viewer/Plain.php" />
- <install name="lib/Horde/Mime/Viewer/Rar.php" as="Horde/Mime/Viewer/Rar.php" />
- <install name="lib/Horde/Mime/Viewer/Report.php" as="Horde/Mime/Viewer/Report.php" />
- <install name="lib/Horde/Mime/Viewer/Rfc822.php" as="Horde/Mime/Viewer/Rfc822.php" />
- <install name="lib/Horde/Mime/Viewer/Richtext.php" as="Horde/Mime/Viewer/Richtext.php" />
- <install name="lib/Horde/Mime/Viewer/Rpm.php" as="Horde/Mime/Viewer/Rpm.php" />
- <install name="lib/Horde/Mime/Viewer/Rtf.php" as="Horde/Mime/Viewer/Rtf.php" />
- <install name="lib/Horde/Mime/Viewer/Security.php" as="Horde/Mime/Viewer/Security.php" />
- <install name="lib/Horde/Mime/Viewer/Simple.php" as="Horde/Mime/Viewer/Simple.php" />
- <install name="lib/Horde/Mime/Viewer/Smil.php" as="Horde/Mime/Viewer/Smil.php" />
- <install name="lib/Horde/Mime/Viewer/Source.php" as="Horde/Mime/Viewer/Source.php" />
- <install name="lib/Horde/Mime/Viewer/Srchighlite.php" as="Horde/Mime/Viewer/Srchighlite.php" />
- <install name="lib/Horde/Mime/Viewer/Tgz.php" as="Horde/Mime/Viewer/Tgz.php" />
- <install name="lib/Horde/Mime/Viewer/Tnef.php" as="Horde/Mime/Viewer/Tnef.php" />
- <install name="lib/Horde/Mime/Viewer/Vcard.php" as="Horde/Mime/Viewer/Vcard.php" />
- <install name="lib/Horde/Mime/Viewer/Wordperfect.php" as="Horde/Mime/Viewer/Wordperfect.php" />
- <install name="lib/Horde/Mime/Viewer/Zip.php" as="Horde/Mime/Viewer/Zip.php" />
<install name="lib/Horde/Mime/Address.php" as="Horde/Mime/Address.php" />
<install name="lib/Horde/Mime/Exception.php" as="Horde/Mime/Exception.php" />
<install name="lib/Horde/Mime/Headers.php" as="Horde/Mime/Headers.php" />
<install name="lib/Horde/Mime/Magic.php" as="Horde/Mime/Magic.php" />
<install name="lib/Horde/Mime/Mail.php" as="Horde/Mime/Mail.php" />
<install name="lib/Horde/Mime/Part.php" as="Horde/Mime/Part.php" />
- <install name="lib/Horde/Mime/Viewer.php" as="Horde/Mime/Viewer.php" />
<install name="lib/Horde/Mime/mime.mapping.php" as="Horde/Mime/mime.mapping.php" />
<install name="lib/Horde/Mime.php" as="Horde/Mime.php" />
</filelist>
+++ /dev/null
-<A HREF=http://66.102.7.147/>link</A>
+++ /dev/null
-<A HREF=http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D>link</A>
+++ /dev/null
-<A HREF=ht://www.google.com/>link</A>
+++ /dev/null
-<A HREF=http://google.com/>link</A>
+++ /dev/null
-<A HREF=http://www.google.com./>link</A>
+++ /dev/null
-<A HREF="javascript:document.location='http://www.google.com/'">link</A>
+++ /dev/null
-<A HREF=http://www.gohttp://www.google.com/ogle.com/>link</A>
+++ /dev/null
---TEST--
-Horde_Mime_Viewer_html: URL dereferer tests
---SKIPIF--
-skip: Horde_Mime_Viewer has too many dependencies.
---FILE--
-<?php
-
-$dirname = dirname(__FILE__);
-require_once $dirname . '/../../../lib/Horde/Mime/Part.php';
-require_once $dirname . '/../../../lib/Horde/Mime/Viewer.php';
-require_once 'Horde.php';
-
-class Registry {
- function get($param, $app = null)
- {
- if ($param == 'webroot' || $app == 'horde') {
- return '/horde';
- }
- die("Can't emulate Registry. \$param: $param, \$app: $app");
- }
-}
-
-class Browser {
- function isBrowser($agent)
- {
- return $agent == 'msie';
- }
-}
-
-$conf = array(
- 'server' => array(
- 'name' => 'www.example.com',
- 'port' => 80
- ),
- 'use_ssl' => 0
-);
-$registry = new Registry();
-$browser = new Browser();
-
-for ($i = 1; $i <= 7; $i++) {
- $part = new Horde_Mime_Part();
- $part->setType('text/html');
- $part->setContents(file_get_contents($dirname . '/fixtures/url' . $i . '.html'));
- $viewer = Horde_Mime_Viewer::factory($part, 'text/html');
- echo $viewer->render();
-}
-
-?>
---EXPECT--
-<A href="http://www.example.com/horde/services/go.php?url=http%3A%2F%2F66.102.7.147%2F">link</A>
-<A href="http://www.example.com/horde/services/go.php?url=http%3A%2F%2F%2577%2577%2577%252E%2567%256F%256F%2567%256C%2565%252E%2563%256F%256D">link</A>
-<A href="http://www.example.com/horde/services/go.php?url=ht%3A%2F%2Fwww.google.com%2F">link</A>
-<A href="http://www.example.com/horde/services/go.php?url=http%3A%2F%2Fgoogle.com%2F">link</A>
-<A href="http://www.example.com/horde/services/go.php?url=http%3A%2F%2Fwww.google.com.%2F">link</A>
-<A href="http://www.example.com/horde/services/go.php?url=XSSCleaneddocument.location%3D%27http%3A%2F%2Fwww.google.com%2F%27">link</A>
-<A href="http://www.example.com/horde/services/go.php?url=http%3A%2F%2Fwww.gohttp%3A%2F%2Fwww.google.com%2Fogle.com%2F">link</A>
+++ /dev/null
---TEST--
-PHP source viewer
---SKIPIF--
-skip: Horde_Mime_Viewer has too many dependencies.
---FILE--
-<?php
-
-require_once dirname(__FILE__) . '/../../../lib/Horde/Mime/Part.php';
-require_once dirname(__FILE__) . '/../../../lib/Horde/Mime/Viewer.php';
-
-ini_set('highlight.comment', 'comment');
-ini_set('highlight.default', 'default');
-ini_set('highlight.keyword', 'keyword');
-ini_set('highlight.string', 'string');
-ini_set('highlight.html', 'html');
-
-$part = new Horde_Mime_Part();
-$part->setType('application/x-php');
-$part->setContents(str_replace('<?php ', '', highlight_string('<?php highlight_file(__FILE__);', true)));
-
-$viewer = Horde_Mime_Viewer::factory($part);
-echo $viewer->render();
-?>
---EXPECT--
-<ol class="code-listing striped">
-<li id="l1"><span class="default">highlight_file</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">);</span></li>
-</ol>
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer:: class provides an abstracted interface to render
+ * MIME data into various formats. It depends on both a set of
+ * Horde_Mime_Viewer_* drivers which handle the actual rendering, and a
+ * configuration file to map MIME types to drivers.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Anil Madhavapeddy <anil@recoil.org>
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer
+{
+ /**
+ * The config array. This array is shared between all instances of
+ * Horde_Mime_Viewer.
+ *
+ * @var array
+ */
+ static protected $_config = array();
+
+ /**
+ * The driver cache array. This array is shared between all instances of
+ * Horde_Mime_Viewer.
+ *
+ * @var array
+ */
+ static protected $_drivercache = array();
+
+ /**
+ * Attempts to return a concrete Horde_Mime_Viewer_* object based on the
+ * MIME type.
+ *
+ * @param Horde_Mime_Part $mime_part An object with the information to be
+ * rendered.
+ * @param string $mime_type The MIME type (overrides the value
+ * in the MIME part).
+ *
+ * @return Horde_Mime_Viewer The Horde_Mime_Viewer object, or false on
+ * error.
+ */
+ static final public function factory($mime_part, $mime_type = null)
+ {
+ if (is_null($mime_type)) {
+ $mime_type = $mime_part->getType();
+ }
+
+ /* Spawn the relevant driver, and return it (or false on failure). */
+ if (($ob = self::_getDriver($mime_type, $GLOBALS['registry']->getApp())) &&
+ self::_resolveDriver($ob['driver'], $ob['app']) &&
+ class_exists($ob['class'])) {
+ $conf = array_merge(self::$_config['mime_drivers'][$ob['app']][$ob['driver']], array('_driver' => $ob['driver']));
+ return new $ob['class']($mime_part, $conf);
+ }
+
+ return false;
+ }
+
+ /**
+ * Given a MIME type, this function will return an appropriate icon.
+ *
+ * @param string $mime_type The MIME type that we need an icon for.
+ *
+ * @return string The URL to the appropriate icon.
+ */
+ static final public function getIcon($mime_type)
+ {
+ $app = $GLOBALS['registry']->getApp();
+ $ob = self::_getIcon($mime_type, $app);
+
+ if (is_null($ob)) {
+ if ($app == 'horde') {
+ return null;
+ }
+
+ $obHorde = self::_getIcon($mime_type, 'horde');
+ return is_null($obHorde) ? null : $obHorde['url'];
+ } elseif (($ob['match'] !== 0) && ($app != 'horde')) {
+ $obHorde = self::_getIcon($mime_type, 'horde');
+ if (!is_null($ob['match']) &&
+ ($obHorde['match'] < $ob['match'])) {
+ return $obHorde['url'];
+ }
+ }
+
+ return $ob['url'];
+ }
+
+ /**
+ * Given a MIME type and an app name, determine which driver can best
+ * handle the data.
+ *
+ * @param string $mime_type MIME type to resolve.
+ * @param string $app App in which to search for the driver.
+ *
+ * @return mixed Returns false if driver could not be found. Otherwise,
+ * an array with the following elements:
+ * <pre>
+ * 'app' - (string) The app containing the driver (e.g. 'horde')
+ * 'driver' - (string) Name of driver (e.g. 'enscript')
+ * 'exact' - (boolean) Was the driver and exact match?
+ * </pre>
+ */
+ static final protected function _getDriver($mime_type, $app = 'horde')
+ {
+ $sig = $mime_type . '|' . $app;
+ if (isset(self::$_drivercache[$sig])) {
+ return self::$_drivercache[$sig];
+ }
+
+ /* Make sure horde config is loaded. */
+ if (empty(self::$_config['mime_drivers']['horde'])) {
+ try {
+ self::$_config = Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), 'horde');
+ } catch (Horde_Exception $e) {
+ return false;
+ }
+ }
+
+ /* Make sure app's config is loaded. There is no requirement that
+ * an app have a separate config, so ignore any errors. */
+ if (($app != 'horde') && empty(self::$_config['mime_drivers'][$app])) {
+ try {
+ self::$_config = Horde_Array::array_merge_recursive_overwrite(self::$_config, Horde::loadConfiguration('mime_drivers.php', array('mime_drivers', 'mime_drivers_map'), $app));
+ } catch (Horde_Exception $e) {}
+ }
+
+ $driver = '';
+ $exact = false;
+
+ list($primary_type,) = explode('/', $mime_type, 2);
+ $allSub = $primary_type . '/*';
+
+ /* If the app doesn't exist in $mime_drivers_map, check for Horde-wide
+ * viewers. */
+ if (!isset(self::$_config['mime_drivers_map'][$app]) &&
+ ($app != 'horde')) {
+ return self::_getDriver($mime_type, 'horde');
+ }
+
+ $dr = isset(self::$_config['mime_drivers'][$app]) ? self::$_config['mime_drivers'][$app] : array();
+ $map = self::$_config['mime_drivers_map'][$app];
+
+ /* If an override exists for this MIME type, then use that */
+ if (isset($map['overrides'][$mime_type])) {
+ $driver = $map['overrides'][$mime_type];
+ $exact = true;
+ } elseif (isset($map['overrides'][$allSub])) {
+ $driver = $map['overrides'][$allSub];
+ $exact = true;
+ } elseif (isset($map['registered'])) {
+ /* Iterate through the list of registered drivers, and see if
+ * this MIME type exists in the MIME types that they claim to
+ * handle. If the driver handles it, then assign it as the
+ * rendering driver. If we find a generic handler, keep iterating
+ * to see if we can find a specific handler. */
+ foreach ($map['registered'] as $val) {
+ if (in_array($mime_type, $dr[$val]['handles'])) {
+ $driver = $val;
+ $exact = true;
+ break;
+ } elseif (in_array($allSub, $dr[$val]['handles'])) {
+ $driver = $val;
+ }
+ }
+ }
+
+ /* If this is an application specific app, and an exact match was
+ not found, search for a Horde-wide specific driver. Only use the
+ Horde-specific driver if it is NOT the 'default' driver AND the
+ Horde driver is an exact match. */
+ if (!$exact && ($app != 'horde')) {
+ $ob = self::_getDriver($mime_type, 'horde');
+ if (empty($driver) ||
+ (($ob['driver'] != 'default') && $ob['exact'])) {
+ $driver = $ob['driver'];
+ $app = 'horde';
+ }
+ }
+
+ /* If the 'default' driver exists in this app, fall back to that. */
+ if (empty($driver) && self::_resolveDriver('default', $app)) {
+ $driver = 'default';
+ }
+
+ if (empty($driver)) {
+ return false;
+ }
+
+ self::$_drivercache[$sig] = array(
+ 'app' => $app,
+ 'class' => (($app == 'horde') ? '' : $app . '_') . 'Horde_Mime_Viewer_' . $driver,
+ 'driver' => $driver,
+ 'exact' => $exact,
+ );
+
+ return self::$_drivercache[$sig];
+ }
+
+ /**
+ * Given a driver and an application, attempts to load the library file.
+ *
+ * @param string $driver Driver name.
+ * @param string $app Application name.
+ *
+ * @return boolean True if library file was loaded.
+ */
+ static final protected function _resolveDriver($driver = 'default',
+ $app = 'horde')
+ {
+ $driver = ucfirst($driver);
+
+ $file = ($app == 'horde')
+ ? dirname(__FILE__) . '/Viewer/' . $driver . '.php'
+ : $GLOBALS['registry']->applications[$app]['fileroot'] . '/lib/Mime/Viewer/' . $driver . '.php';
+
+ return require_once $file;
+ }
+
+ /**
+ * Given an input MIME type and app, this function returns the URL of an
+ * icon that can be associated with it
+ *
+ * @param string $mime_type MIME type to get the icon for.
+ *
+ * @return mixed Null if not found, or an array with the following keys:
+ * <pre>
+ * 'exact' - (integer) How exact the match is. Null if no match.
+ * 0 - 'exact'
+ * 1 - 'primary'
+ * 2 - 'driver',
+ * 3 - 'default'
+ * 'url' - (string) URL to an icon, or null if none could be found.
+ * </pre>
+ */
+ static final protected function _getIcon($mime_type, $app = 'horde')
+ {
+ if (!($ob = self::_getDriver($mime_type, $app))) {
+ return null;
+ }
+ $driver = $ob['driver'];
+
+ list($primary_type,) = explode('/', $mime_type, 2);
+ $allSub = $primary_type . '/*';
+ $ret = null;
+
+ /* If the app doesn't exist in $mime_drivers, return now. */
+ if (!isset(self::$_config['mime_drivers'][$app])) {
+ return null;
+ }
+
+ $dr = self::$_config['mime_drivers'][$app];
+
+ /* If a specific icon for this driver and mimetype is defined,
+ then use that. */
+ if (isset($dr[$driver]['icons'])) {
+ $icondr = $dr[$driver]['icons'];
+ $iconList = array($mime_type => 0, $allSub => 1, 'default' => 2);
+ foreach ($iconList as $key => $val) {
+ if (isset($icondr[$key])) {
+ $ret = array('match' => $val, 'url' => $icondr[$key]);
+ break;
+ }
+ }
+ }
+
+ /* Try to use a default icon if none already obtained. */
+ if (is_null($ret['url']) &&
+ isset($dr['default']['icons']['default'])) {
+ $ret = array('match' => 3, 'url' => $dr['default']['icons']['default']);
+ }
+
+ if (!is_null($ret)) {
+ $ret['url'] = Horde_Themes::img('mime/' . $ret['url'], $app);
+ }
+
+ return $ret;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Audio class sends audio parts to the browser for
+ * handling by the browser, a plugin, or a helper application.
+ *
+ * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Audio extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $this->_mimepart->getContents(),
+ 'status' => array(),
+ 'type' => $this->_mimepart->getType()
+ )
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Css class renders CSS source as HTML with an effort
+ * to remove potentially malicious code.
+ *
+ * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Css extends Horde_Mime_Viewer_Source
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => true,
+ 'raw' => false
+ );
+
+ /**
+ * Attribute preg patterns.
+ *
+ * @var array
+ */
+ protected $_attrPatterns = array(
+ // Attributes
+ '!([-\w]+\s*):!s' => '<span class="attr"">\\1</span>:',
+ // Values
+ '!:(\s*)(.+?)(\s*;)!s' => ':\\1<span class="value">\\2</span><span class="eol">\\3</span>',
+ // URLs
+ '!(url\([\'"]?)(.*?)([\'"]?\))!s' => '<span class="url">\\1<span class="file">\\2</span>\\3</span>',
+ // Colors
+ '!(#[[:xdigit:]]{3,6})!s' => '<span class="color">\\1</span>',
+ // Parentheses
+ '!({|})!s' => '<span class="parentheses">\\1</span>',
+ // Unity
+ '!(em|px|%)\b!s' => '<em>\\1</em>'
+ );
+
+ /**
+ * Handles preg patterns.
+ *
+ * @var array
+ */
+ protected $_handlesPatterns = array(
+ // HTML Tags
+ '!\b(body|h\d|a|span|div|acronym|small|strong|em|pre|ul|ol|li|p)\b!s' => '<span class="htag">\\1</span>\\2',
+ // IDs
+ '!(#[-\w]+)!s' => '<span class="id">\\1</span>',
+ // Class
+ '!(\.[-\w]+)\b!s' => '<span class="class">\\1</span>',
+ // METAs
+ '!(:link|:visited|:hover|:active|:first-letter)!s' => '<span class="metac">\\1</span>'
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ $ret = $this->_renderInline();
+
+ // Need Horde headers for CSS tags.
+ reset($ret);
+ Horde::startBuffer();
+ require $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc';
+ echo $ret[key($ret)]['data'];
+ require $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
+ $ret[key($ret)]['data'] = Horde::endBuffer();
+
+ return $ret;
+ }
+
+ /**
+ * Return the rendered inline version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInline()
+ {
+ $css = preg_replace_callback('!(}|\*/).*?({|/\*)!s', array($this, '_handles'), htmlspecialchars($this->_mimepart->getContents(), ENT_NOQUOTES));
+ $css = preg_replace_callback('!{[^}]*}!s', array($this, '_attributes'), $css);
+ $css = preg_replace_callback('!/\*.*?\*/!s', array($this, '_comments'), $css);
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $this->_lineNumber(trim($css)),
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+
+ /**
+ * TODO
+ */
+ protected function _comments($matches)
+ {
+ return '<span class="comment">' .
+ preg_replace('!(http://[/\w-.]+)!s', '<a href="\\1">\\1</a>', $matches[0]) .
+ '</span>';
+ }
+
+ /**
+ * TODO
+ */
+ protected function _attributes($matches)
+ {
+ return preg_replace(array_keys($this->_attrPatterns), array_values($this->_attrPatterns), $matches[0]);
+ }
+
+ /**
+ * TODO
+ */
+ protected function _handles($matches)
+ {
+ return preg_replace(array_keys($this->_handlesPatterns), array_values($this->_handlesPatterns), $matches[0]);
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Deb class renders out lists of files in Debian
+ * packages by using the dpkg tool to query the package.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Anil Madhavapeddy <anil@recoil.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Deb extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => true,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Metadata for the current viewer/data.
+ *
+ * @var array
+ */
+ protected $_metadata = array(
+ 'compressed' => true,
+ 'embedded' => false,
+ 'forceinline' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ $ret = $this->_renderInfo();
+ if (!empty($ret)) {
+ reset($ret);
+ $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
+ }
+ return $ret;
+ }
+
+ /**
+ * Return the rendered information about the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInfo()
+ {
+ /* Check to make sure the viewer program exists. */
+ if (!isset($this->_conf['location']) ||
+ !file_exists($this->_conf['location'])) {
+ return array();
+ }
+
+ $tmp_deb = Horde::getTempFile('horde_deb');
+
+ file_put_contents($tmp_deb, $this->_mimepart->getContents());
+
+ $fh = popen($this->_conf['location'] . " -f $tmp_deb 2>&1", 'r');
+ while (($rc = fgets($fh, 8192))) {
+ $data .= $rc;
+ }
+ pclose($fh);
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => '<pre>' . htmlspecialchars($data) . '</pre>',
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Default class simply prints out the encapsulated
+ * content. It exists as a fallback if no other intelligent rendering
+ * mechanism could be used.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Anil Madhavapeddy <anil@recoil.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Default extends Horde_Mime_Viewer_Driver
+{
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Driver:: class provides the API for specific viewer
+ * drivers to extend.
+ *
+ * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Driver
+{
+ /**
+ * Viewer configuration.
+ *
+ * @var array
+ */
+ protected $_conf = array();
+
+ /**
+ * The Horde_Mime_Part object to render.
+ *
+ * @var Horde_Mime_Part
+ */
+ protected $_mimepart = null;
+
+ /**
+ * Viewer parameters.
+ *
+ * @var array
+ */
+ protected $_params = array();
+
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => false,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Metadata for the current viewer/data.
+ *
+ * @var array
+ */
+ protected $_metadata = array(
+ // Is the part *data* compressed (not the rendered data)?
+ 'compressed' => false,
+ // Does this part contain emebedded MIME data?
+ 'embedded' => false,
+ // Force inline display of this part?
+ 'forceinline' => false
+ );
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Mime_Part $mime_part Reference to an object with the
+ * information to be rendered.
+ * @param array $conf Configuration specific to the
+ * driver.
+ */
+ public function __construct($mime_part, $conf = array())
+ {
+ $this->_mimepart = $mime_part;
+ $this->_conf = $conf;
+ }
+
+ /**
+ * Sets the Horde_Mime_Part object for the class.
+ *
+ * @param Horde_Mime_Part $mime_part The object with the information to
+ * be rendered.
+ */
+ public function setMIMEPart($mime_part)
+ {
+ $this->_mimepart = $mime_part;
+ }
+
+ /**
+ * Set parameters for use with this object.
+ *
+ * @param array $params An array of params to add to the internal
+ * params list.
+ */
+ public function setParams($params = array())
+ {
+ $this->_params = array_merge($this->_params, $params);
+ }
+
+ /**
+ * Return the rendered version of the Horde_Mime_Part object.
+ *
+ * @param string $mode The mode:
+ * <pre>
+ * 'full' - A full representation of the MIME part, for use in a view
+ * where the output to the browser can be set to the value
+ * returned in 'type'. This mode should only return a single
+ * MIME ID entry for viewing and should not return any status
+ * information.
+ * 'inline' - A representation of the MIME part that can be viewed inline
+ * on a text/html page that may contain other HTML elements.
+ * 'info' - A representation of the MIME part that can be viewed inline
+ * on an text/html page that may contain other HTML elements.
+ * This view is not a full view, but rather a condensed view of
+ * the contents of the MIME part. This view is intended to be
+ * displayed to the user with the intention that this MIME part's
+ * subparts may also independently be viewed inline.
+ * 'raw' - The raw data of the MIME part, generally useful for downloading
+ * a part. This view exists in case this raw data needs to be
+ * altered in any way.
+ * </pre>
+ *
+ * @return array An array. The keys are the MIME parts that were handled
+ * by the driver. The values are either null (which
+ * indicates the driver is recommending that this
+ * particular MIME ID should not be displayed) or an array
+ * with the following keys:
+ * <pre>
+ * 'data' - (string) The rendered data.
+ * 'status' - (array) An array of status information to be displayed to
+ * the user. Consists of arrays with the following keys:
+ * 'class' - (string) The class to use for display.
+ * 'img' - (string) An image to display.
+ * 'text' - (array) The text to display.
+ * 'type' - (string) The MIME type of the rendered data.
+ * </pre>
+ */
+ public function render($mode)
+ {
+ switch ($mode) {
+ case 'full':
+ try {
+ return $this->_render();
+ } catch (Horde_Exception $e) {
+ $error = $e;
+ }
+ break;
+
+ case 'inline':
+ try {
+ return $this->_renderInline();
+ } catch (Horde_Exception $e) {
+ $error = $e;
+ }
+
+ case 'info':
+ try {
+ return $this->_renderInfo();
+ } catch (Horde_Exception $e) {
+ $error = $e;
+ }
+
+ case 'raw':
+ try {
+ return $this->_renderRaw();
+ } catch (Horde_Exception $e) {
+ $error = $e;
+ }
+ }
+
+ // TODO: Error handling
+ }
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _render()
+ {
+ $viewer = $this->_getViewer();
+ return $viewer
+ ? $viewer->render('full')
+ : array();
+ }
+
+ /**
+ * Return the rendered inline version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _renderInline()
+ {
+ $viewer = $this->_getViewer();
+ return $viewer
+ ? $viewer->render('inline')
+ : array();
+ }
+
+ /**
+ * Return the rendered information about the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _renderInfo()
+ {
+ $viewer = $this->_getViewer();
+ return $viewer
+ ? $viewer->render('info')
+ : array();
+ }
+
+ /**
+ * Return the rendered information about the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _renderRaw()
+ {
+ $viewer = $this->_getViewer();
+ return $viewer
+ ? $viewer->render('raw')
+ : array();
+ }
+
+ /**
+ * Can this driver render the the data?
+ *
+ * @param string $mode The mode. Either 'full', 'inline', 'info', or
+ * 'raw'.
+ *
+ * @return boolean True if the driver can render the data for the given
+ * view.
+ */
+ public function canRender($mode)
+ {
+ $viewer = $this->_getViewer();
+ if ($viewer) {
+ return $viewer->canRender($mode);
+ }
+
+ switch ($mode) {
+ case 'full':
+ case 'info':
+ case 'raw':
+ return $this->_capability[$mode];
+
+ case 'inline':
+ return $this->getConfigParam('inline') &&
+ ($this->_metadata['forceinline'] ||
+ ($this->_capability['inline'] &&
+ ($this->_mimepart->getDisposition() != 'attachment')));
+
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Does this MIME part possibly contain embedded MIME parts?
+ *
+ * @return boolean True if this driver supports parsing embedded MIME
+ * parts.
+ */
+ public function embeddedMimeParts()
+ {
+ $viewer = $this->_getViewer();
+ return $viewer
+ ? $viewer->embeddedMimeParts()
+ : $this->_metadata['embedded'];
+ }
+
+ /**
+ * If this MIME part can contain embedded MIME part(s), and those part(s)
+ * exist, return a representation of that data.
+ *
+ * @return mixed A Horde_Mime_Part object representing the embedded data.
+ * Returns null if no embedded MIME part(s) exist.
+ */
+ public function getEmbeddedMimeParts()
+ {
+ $viewer = $this->_getViewer();
+ return $viewer
+ ? $viewer->getEmbeddedMimeParts()
+ : $this->_getEmbeddedMimeParts();
+ }
+
+ /**
+ * If this MIME part can contain embedded MIME part(s), and those part(s)
+ * exist, return a representation of that data.
+ *
+ * @return mixed A Horde_Mime_Part object representing the embedded data.
+ * Returns null if no embedded MIME part(s) exist.
+ */
+ protected function _getEmbeddedMimeParts()
+ {
+ return null;
+ }
+
+ /**
+ * Return a configuration parameter for the current viewer.
+ *
+ * @param string $param The parameter name.
+ *
+ * @return mixed The value of the parameter; returns null if the
+ * parameter doesn't exist.
+ */
+ public function getConfigParam($param)
+ {
+ return isset($this->_conf[$param]) ? $this->_conf[$param] : null;
+ }
+
+ /**
+ * Returns the driver name for the current object.
+ *
+ * @return string The driver name.
+ */
+ public function getDriver()
+ {
+ return $this->_conf['_driver'];
+ }
+
+ /**
+ * Returns metadata information on the viewer/data.
+ *
+ * @param string $data The metadata key.
+ *
+ * @return mixed The requested information, or null if the key doesn't
+ * exist.
+ */
+ public function getMetadata($data)
+ {
+ return isset($this->_metadata[$data])
+ ? $this->_metadata[$data]
+ : null;
+ }
+
+ /**
+ * Return the underlying MIME Viewer for this part.
+ *
+ * @return mixed A Horde_Mime_Viewer object, or false if not found.
+ */
+ protected function _getViewer()
+ {
+ return false;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Enriched class renders out plain text from enriched
+ * content tags, ala RFC 1896.
+ *
+ * By RFC, we must do the minimal conformance measures of: A minimal
+ * text/enriched implementation is one that converts "<<" to "<",
+ * removes everything between a <param> command and the next balancing
+ * </param> removes all other formatting commands (all text enclosed
+ * in angle brackets), and outside of <nofill> environments converts
+ * any series of n CRLFs to n-1 CRLFs, and converts any lone CRLF
+ * pairs to SPACE.
+ *
+ * We don't qualify as we don't currently track the <nofill>
+ * environment, that is we do CRLF conversion even if <nofill> is
+ * specified in the text, but we're close at least.
+ *
+ * Copyright 2001-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Eric Rostetter <eric.rostetter@physics.utexas.edu>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Enriched extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => true,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => '<html><body>' . $this->_toHTML(false) . '</body></html>',
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $this->_mimepart->getCharset()
+ )
+ );
+ }
+
+ /**
+ * Return the rendered inline version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInline()
+ {
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => Horde_String::convertCharset($this->_toHTML(true), $this->_mimepart->getCharset()),
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+
+ /**
+ * Convert the enriched text to HTML.
+ *
+ * @param string $inline Rendered inline?
+ *
+ * @return string The HTML-ified version of the MIME part contents.
+ */
+ protected function _toHTML($inline)
+ {
+ $text = trim($this->_mimepart->getContents());
+ if (!strlen($text)) {
+ return array();
+ }
+
+ // We add space at the beginning and end of the string as it will
+ // make some regular expression checks later much easier (so we
+ // don't have to worry about start/end of line characters)
+ $text = ' ' . $text . ' ';
+
+ // We need to preserve << tags, so map them to ascii 1 or ascii 255
+ // We make the assumption here that there would never be an ascii
+ // 1 in an email, which may not be valid, but seems reasonable...
+ // ascii 255 would work if for some reason you don't like ascii 1
+ // ascii 0 does NOT seem to work for this, though I'm not sure why
+ $text = str_replace('<<', chr(1), $text);
+
+ // Remove any unrecognized tags in the text (via RFC minimal specs)
+ // any tags we just don't want to implement can also be removed here
+ // Note that this will remove any html links, but this is intended
+ $implementedTags = '<param><bold><italic><underline><fixed><excerpt>' .
+ '<smaller><bigger><center><color><fontfamily>' .
+ '<flushleft><flushright><flushboth><paraindent>';
+ // $unImplementedTags = '<nofill><lang>';
+ $text = strip_tags($text, $implementedTags);
+
+ // restore the << tags as < tags now...
+ $text = str_replace(chr(1), '<<', $text);
+ // $text = str_replace(chr(255), '<', $text);
+
+ $replace = array(
+ // Get color parameters into a more useable format.
+ '/<color><param>([\da-fA-F]+),([\da-fA-F]+),([\da-fA-F]+)<\/param>/Uis' => '<color r=\1 g=\2 b=\3>',
+ '/<color><param>(red|blue|green|yellow|cyan|magenta|black|white)<\/param>/Uis' => '<color n=\1>',
+
+ // Get font family parameters into a more useable format.
+ '/<fontfamily><param>(\w+)<\/param>/Uis' => '<fontfamily f=\1>',
+
+ /* Just remove any remaining parameters -- we won't use them.
+ * Any tags with parameters that we want to implement will have
+ * come before this. Someday we hope to use these tags (e.g. for
+ * <color><param> tags). */
+ '/<param>.*<\/param>/Uis' => '',
+
+ /* Single line breaks become spaces, double line breaks are a
+ * real break. This needs to do <nofill> tracking to be compliant
+ * but we don't want to deal with state at this time, so we fake
+ * it some day we should rewrite this to handle <nofill>
+ * correctly. */
+ '/([^\n])\r\n([^\r])/' => '\1 \2',
+ '/(\r\n)\r\n/' => '\1'
+ );
+ $text = preg_replace(array_keys($replace), array_values($replace), $text);
+
+ // We try to protect against bad stuff here.
+ $text = @htmlspecialchars($text, ENT_QUOTES, $this->_mimepart->getCharset());
+
+ // Now convert the known tags to html. Try to remove any tag
+ // parameters to stop people from trying to pull a fast one
+ $replace = array(
+ '/(?<!<)<bold.*>(.*)<\/bold>/Uis' => '<span style="font-weight: bold">\1</span>',
+ '/(?<!<)<italic.*>(.*)<\/italic>/Uis' => '<span style="font-style: italic">\1</span>',
+ '/(?<!<)<underline.*>(.*)<\/underline>/Uis' => '<span style="text-decoration: underline">\1</span>'
+ );
+ $text = preg_replace(array_keys($replace), array_values($replace), $text);
+
+ $text = preg_replace_callback('/(?<!<)<color r=([\da-fA-F]+) g=([\da-fA-F]+) b=([\da-fA-F]+)>(.*)<\/color>/Uis', array($this, 'colorize'), $text);
+
+ $replace = array(
+ '/(?<!<)<color n=(red|blue|green|yellow|cyan|magenta|black|white)>(.*)<\/color>/Uis' => '<span style="color: \1">\2</span>',
+ '/(?<!<)<fontfamily>(.*)<\/fontfamily>/Uis' => '\1',
+ '/(?<!<)<fontfamily f=(\w+)>(.*)<\/fontfamily>/Uis' => '<span style="font-family: \1">\2</span>',
+ '/(?<!<)<smaller.*>/Uis' => '<span style="font-size: smaller">',
+ '/(?<!<)<\/smaller>/Uis' => '</span>',
+ '/(?<!<)<bigger.*>/Uis' => '<span style="font-size: larger">',
+ '/(?<!<)<\/bigger>/Uis' => '</span>',
+ '/(?<!<)<fixed.*>(.*)<\/fixed>/Uis' => '<font face="fixed">\1</font>',
+ '/(?<!<)<center.*>(.*)<\/center>/Uis' => '<div align="center">\1</div>',
+ '/(?<!<)<flushleft.*>(.*)<\/flushleft>/Uis' => '<div align="left">\1</div>',
+ '/(?<!<)<flushright.*>(.*)<\/flushright>/Uis' => '<div align="right">\1</div>',
+ '/(?<!<)<flushboth.*>(.*)<\/flushboth>/Uis' => '<div align="justify">\1</div>',
+ '/(?<!<)<paraindent.*>(.*)<\/paraindent>/Uis' => '<blockquote>\1</blockquote>',
+ '/(?<!<)<excerpt.*>(.*)<\/excerpt>/Uis' => '<blockquote>\1</blockquote>'
+ );
+ $text = preg_replace(array_keys($replace), array_values($replace), $text);
+
+ // Replace << with < now (from translated HTML form).
+ $text = str_replace('<<', '<', $text);
+
+ // Now we remove the leading/trailing space we added at the
+ // start.
+ $text = preg_replace('/^ (.*) $/s', '\1', $text);
+
+ // Make URLs clickable.
+ $text = Horde_Text_Filter::filter($text, 'linkurls', array(
+ 'callback' => 'Horde::externalUrl'
+ ));
+
+ /* Wordwrap -- note this could impact on our above RFC compliance *IF*
+ * we honored nofill tags (which we don't yet). */
+ $text = str_replace(array("\t", ' ', "\n "), array(' ', ' ', "\n "), $text);
+
+ if ($text[0] == ' ') {
+ $text = ' ' . substr($text, 1);
+ }
+
+ return '<p class="fixed">' . nl2br($text) . '</p>';
+ }
+
+ /**
+ * TODO
+ */
+ public function colorize($colors)
+ {
+ for ($i = 1; $i < 4; $i++) {
+ $colors[$i] = sprintf('%02X', round(hexdec($colors[$i]) / 255));
+ }
+ return '<span style="color: #' . $colors[1] . $colors[2] . $colors[3] . '">' . $colors[4] . '</span>';
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Html class renders out HTML text with an effort to
+ * remove potentially malicious code.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Anil Madhavapeddy <anil@recoil.org>
+ * @author Jon Parise <jon@horde.org>
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => true,
+ 'raw' => false
+ );
+
+ /**
+ * The CSS used to display the phishing warning.
+ *
+ * @var string
+ */
+ protected $_phishCss = 'padding: 1px;margin-bottom: 3px;font-size: 90%;border: 1px solid #800;background: #e81222;color: #fff;width: 100%;';
+
+ /**
+ * Phishing status of last call to _phishingCheck().
+ *
+ * @var boolean
+ */
+ protected $_phishWarn = false;
+
+ /**
+ * Temp array for storing data when parsing the HTML document.
+ *
+ * @var array
+ */
+ protected $_tmp = array();
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ $html = $this->_cleanHTML($this->_mimepart->getContents(), array('inline' => false));
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $html['html'],
+ 'status' => array(),
+ 'type' => $this->_mimepart->getType(true)
+ )
+ );
+ }
+
+ /**
+ * Return the rendered inline version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInline()
+ {
+ $html = $this->_cleanHTML($this->_mimepart->getContents(), array('inline' => true));
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => Horde_String::convertCharset($html['data'], $this->_mimepart->getCharset()),
+ 'status' => $html['status'],
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+
+ /**
+ * Filters active content, dereferences external links, detects phishing,
+ * etc.
+ *
+ * @todo Use IP checks from
+ * http://lxr.mozilla.org/mailnews/source/mail/base/content/phishingDetector.js.
+ *
+ * @param string $data The HTML data.
+ * @param array $options Additional options:
+ * <pre>
+ * 'charset' - (string) The charset of $data.
+ * DEFAULT: The base part charset.
+ * 'inline' - (boolean) Are we viewing inline?
+ * DEFAULT: false
+ * 'noprefetch' - (boolean) Disable DNS prefetching?
+ * DEFAULT: false
+ * 'phishing' - (boolean) Do phishing highlighting even if not viewing
+ * inline.
+ * DEFAULT: false.
+ * </pre>
+ *
+ * @return string The cleaned HTML string.
+ */
+ protected function _cleanHTML($data, $options = array())
+ {
+ global $browser;
+
+ $strip_style_attributes = (!empty($options['inline']) &&
+ (($browser->isBrowser('mozilla') &&
+ ($browser->getMajor() == 4)) ||
+ $browser->isBrowser('msie')));
+
+ $data = Horde_Text_Filter::filter($data, array('cleanhtml', 'xss'), array(
+ array(
+ 'charset' => isset($options['charset']) ? $options['charset'] : $this->_mimepart->getCharset()
+ ),
+ array(
+ 'noprefetch' => !empty($options['noprefetch']),
+ 'return_dom' => true,
+ 'strip_styles' => (!empty($options['inline']) || $strip_style_attributes),
+ 'strip_style_attributes' => $strip_style_attributes
+ )
+ ));
+
+ $this->_tmp = array(
+ 'base' => null,
+ 'inline' => !empty($options['inline']),
+ 'phish' => ((!empty($options['inline']) || !empty($options['phishing'])) && $this->getConfigParam('phishing_check'))
+ );
+ $this->_phishWarn = false;
+
+ $this->_node($data, $data);
+
+ return $data->saveHTML();
+ }
+
+ /**
+ * Process DOM node.
+ *
+ * @param DOMDocument $doc Document node.
+ * @param DOMNode $node Node.
+ */
+ protected function _node($doc, $node)
+ {
+ if ($node->hasChildNodes()) {
+ foreach ($node->childNodes as $child) {
+ if ($child instanceof DOMElement) {
+ switch (strtolower($child->tagName)) {
+ case 'base':
+ /* Deal with <base> tags in the HTML, since they will
+ * screw up our own relative paths. */
+ if ($this->_tmp['inline'] &&
+ $child->hasAttribute('href')) {
+ $base = $child->getAttribute('href');
+ if (substr($base, -1) != '/') {
+ $base .= '/';
+ }
+
+ $this->_tmp['base'] = $base;
+ $child->removeAttribute('href');
+ }
+ break;
+ }
+
+ foreach ($child->attributes as $val) {
+ /* Attempt to fix paths that were relying on a <base>
+ * tag. */
+ if (!is_null($this->_tmp['base']) &&
+ in_array($val->name, array('href', 'src'))) {
+ $child->setAttribute($val->name, $this->_tmp['base'] . ltrim($val->value, '/'));
+ }
+
+ if ($val->name == 'href') {
+ if ($this->_tmp['phish'] &&
+ $this->_phishingCheck($val->value, $child->textContent)) {
+ $this->_phishWarn = true;
+ $child->setAttribute('style', ($child->hasAttribute('style') ? rtrim($child->getAttribute('style'), '; ') . ';' : '') . $this->_phishCss);
+ }
+
+ /* Try to derefer all external references. */
+ $child->setAttribute('href', Horde::externalUrl($val->value));
+ }
+ }
+ }
+
+ $this->_nodeCallback($doc, $child);
+ $this->_node($doc, $child);
+ }
+ }
+ }
+
+ /**
+ * Process DOM node (callback).
+ *
+ * @param DOMDocument $doc Document node.
+ * @param DOMNode $node Node.
+ */
+ protected function _nodeCallback($doc, $node)
+ {
+ }
+
+ /**
+ * Check for phishing exploits.
+ *
+ * @param string $href The HREF value.
+ * @param string $text The text value of the link.
+ *
+ * @return boolean True if phishing is detected.
+ */
+ protected function _phishingCheck($href, $text)
+ {
+ /* For phishing, we are checking whether the displayable text URL is
+ * the same as the HREF URL. If we can't parse the text URL, then we
+ * can't do phishing checks. */
+ $text_url = @parse_url($text);
+ if (!$text_url) {
+ return false;
+ }
+
+ $href_url = parse_url($href);
+
+ /* Only concern ourselves with HTTP and FTP links. */
+ if (!isset($href_url['scheme']) ||
+ !in_array($href_url['scheme'], array('ftp', 'http', 'https'))) {
+ return false;
+ }
+
+ /* Check for case where text is just the domain name. */
+ if (!isset($text_url['host'])) {
+ if (!isset($text_url['path']) ||
+ !preg_match("/^[^\.\s]+(?:\.[^\.\s]+)+$/", $text_url['path'])) {
+ return false;
+ }
+
+ $text_url['host'] = $text_url['path'];
+ }
+
+ /* If port exists on link, and text link has scheme or port defined,
+ * do extra checks:
+ * 1. If port exists on text link, and doesn't match, this is
+ * phishing.
+ * 2. If port doesn't exist on text link, and port does not match
+ * defaults, this is phishing. */
+ if (isset($href_url['port']) &&
+ (isset($text_url['scheme']) || isset($text_url['port']))) {
+ if (!isset($text_url['port'])) {
+ switch ($text_url['scheme']) {
+ case 'ftp':
+ $text_url['port'] = 25;
+ break;
+
+ case 'http':
+ $text_url['port'] = 80;
+ break;
+
+ case 'https':
+ $text_url['port'] = 443;
+ break;
+ }
+ }
+
+ if ($href_url['port'] != $text_url['port']) {
+ return false;
+ }
+ }
+
+ if (strcasecmp($href_url['host'], $text_url['host']) === 0) {
+ return false;
+ }
+
+ /* Don't consider the link a phishing link if the domain is the same
+ * on both links (e.g. adtracking.example.com & www.example.com). */
+ $host1 = explode('.', $href_url['host']);
+ $host2 = explode('.', $text_url['host']);
+
+ return (strcasecmp(implode('.', array_slice($host1, -2)), implode('.', array_slice($host2, -2))) !== 0);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Images class allows images to be displayed.
+ *
+ * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Images extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Mime_Part $mime_part Reference to an object with the
+ * information to be rendered.
+ * @param array $conf Configuration specific to the
+ * driver.
+ */
+ public function __construct($mime_part, $conf = array())
+ {
+ parent::__construct($mime_part, $conf);
+
+ /* TODO: Are there other image types that are compressed? */
+ $this->_metadata['compressed'] = in_array($this->_getType(), array('image/gif', 'image/jpeg', 'image/png'));
+ }
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $this->_mimepart->getContents(),
+ 'status' => array(),
+ 'type' => $this->_getType()
+ )
+ );
+ }
+
+ /**
+ * Return the content-type to use for the image.
+ *
+ * @return string The content-type of the image.
+ */
+ protected function _getType()
+ {
+ $type = $this->_mimepart->getType();
+
+ switch ($type) {
+ case 'image/pjpeg':
+ /* image/jpeg and image/pjpeg *appear* to be the same entity, but
+ * Mozilla (for one) don't seem to want to accept the latter. */
+ return 'image/jpeg';
+
+ case 'image/x-png':
+ /* image/x-png == image/png. */
+ return 'image/png';
+
+ default:
+ return $type;
+ }
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Msexcel class renders out Microsoft Excel
+ * documents in HTML format by using the Gnumeric package.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Anil Madhavapeddy <anil@recoil.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Msexcel extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ /* Check to make sure the viewer program exists. */
+ if (!isset($this->_conf['location']) ||
+ !file_exists($this->_conf['location'])) {
+ return array();
+ }
+
+ $tmp_xls = Horde::getTempFile('horde_msexcel');
+ $tmp_out = Horde::getTempFile('horde_msexcel');
+
+ file_put_contents($tmp_xls, $this->_mimepart->getContents());
+ $args = ' -E Gnumeric_Excel:excel_dsf -T Gnumeric_html:html40 ' . $tmp_xls . ' ' . $tmp_out;
+
+ exec($this->_conf['location'] . $args);
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => file_get_contents($tmp_out),
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Mspowerpoint class renders out Microsoft Powerpoint
+ * documents in HTML format by using the xlHtml package.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Anil Madhavapeddy <anil@recoil.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Mspowerpoint extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ /* Check to make sure the viewer program exists. */
+ if (!isset($this->_conf['location']) ||
+ !file_exists($this->_conf['location'])) {
+ return array();
+ }
+
+ $data = '';
+ $tmp_ppt = Horde::getTempFile('horde_mspowerpoint');
+
+ file_put_contents($tmp_ppt, $this->_mimepart->getContents());
+
+ $fh = popen($this->_conf['location'] . " $tmp_ppt 2>&1", 'r');
+ while (($rc = fgets($fh, 8192))) {
+ $data .= $rc;
+ }
+ pclose($fh);
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $data,
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Msword class renders out Microsoft Word documents
+ * in HTML format by using the AbiWord package.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Anil Madhavapeddy <anil@recoil.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Msword extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ /* Check to make sure the viewer program exists. */
+ if (!isset($this->_conf['location']) ||
+ !file_exists($this->_conf['location'])) {
+ return array();
+ }
+
+ $tmp_word = Horde::getTempFile('msword');
+ $tmp_output = Horde::getTempFile('msword');
+ $tmp_file = str_replace(Horde::getTempDir() . '/', '', $tmp_output);
+
+ file_put_contents($tmp_word, $this->_mimepart->getContents());
+ $args = ' --to=html --to-name=' . $tmp_output . ' ' . $tmp_word;
+
+ exec($this->_conf['location'] . $args);
+
+ if (file_exists($tmp_output)) {
+ $data = file_get_contents($tmp_output);
+ $type = 'text/html';
+ } else {
+ $data = _("Unable to translate this Word document");
+ $type = 'text/plain';
+ }
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $data,
+ 'status' => array(),
+ 'type' => $type . '; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Ooo class renders out OpenOffice.org documents in
+ * HTML format.
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Marko Djukic <marko@oblo.com>
+ * @author Jan Schneider <jan@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Ooo extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Metadata for the current viewer/data.
+ *
+ * @var array
+ */
+ protected $_metadata = array(
+ /* At this point assume that the document takes advantage of ZIP
+ * compression. */
+ 'compressed' => true,
+ 'embedded' => false,
+ 'forceinline' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _render()
+ {
+ $has_xslt = Horde_Util::extensionExists('xslt');
+ $has_ssfile = function_exists('domxml_xslt_stylesheet_file');
+ if (($use_xslt = $has_xslt || $has_ssfile)) {
+ $tmpdir = Horde_Util::createTempDir(true);
+ }
+
+ $fnames = array('content.xml', 'styles.xml', 'meta.xml');
+ $tags = array(
+ 'text:p' => 'p',
+ 'table:table' => 'table border="0" cellspacing="1" cellpadding="0" ',
+ 'table:table-row' => 'tr bgcolor="#cccccc"',
+ 'table:table-cell' => 'td',
+ 'table:number-columns-spanned=' => 'colspan='
+ );
+
+ $zip = Horde_Compress::factory('zip');
+ $list = $zip->decompress($this->_mimepart->getContents(), array('action' => Horde_Compress_Zip::ZIP_LIST));
+
+ foreach ($list as $key => $file) {
+ if (in_array($file['name'], $fnames)) {
+ $content = $zip->decompress($this->_mimepart->getContents(), array(
+ 'action' => Horde_Compress_Zip::ZIP_DATA,
+ 'info' => $list,
+ 'key' => $key
+ ));
+
+ if ($use_xslt) {
+ file_put_contents($tmpdir . $file['name'], $content);
+ } elseif ($file['name'] == 'content.xml') {
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => str_replace(array_keys($tags), array_values($tags), $content),
+ 'status' => array(),
+ 'type' => 'text/html; charset=UTF-8'
+ )
+ );
+ }
+ }
+ }
+
+ if (!Horde_Util::extensionExists('xslt')) {
+ return array();
+ }
+
+ $xsl_file = dirname(__FILE__) . '/Ooo/main_html.xsl';
+
+ if ($has_ssfile) {
+ /* Use DOMXML */
+ $xslt = domxml_xslt_stylesheet_file($xsl_file);
+ $dom = domxml_open_file($tmpdir . 'content.xml');
+ $result = @$xslt->process($dom, array(
+ 'metaFileURL' => $tmpdir . 'meta.xml',
+ 'stylesFileURL' => $tmpdir . 'styles.xml',
+ 'disableJava' => true)
+ );
+ $result = $xslt->result_dump_mem($result);
+ } else {
+ // Use XSLT
+ $xslt = xslt_create();
+ $result = @xslt_process($xslt, $tmpdir . 'content.xml', $xsl_file, null, null, array(
+ 'metaFileURL' => $tmpdir . 'meta.xml',
+ 'stylesFileURL' => $tmpdir . 'styles.xml',
+ 'disableJava' => true)
+ );
+ if (!$result) {
+ $result = xslt_error($xslt);
+ }
+ xslt_free($xslt);
+ }
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $result,
+ 'status' => array(),
+ 'type' => 'text/html; charset=UTF-8'
+ )
+ );
+ }
+}
--- /dev/null
+<!--
+
+ The Contents of this file are made available subject to the terms of
+ either of the following licenses
+
+ - GNU Lesser General Public License Version 2.1
+ - Sun Industry Standards Source License Version 1.1
+
+ Sun Microsystems Inc., October, 2000
+
+ GNU Lesser General Public License Version 2.1
+ =============================================
+ Copyright 2000 by Sun Microsystems, Inc.
+ 901 San Antonio Road, Palo Alto, CA 94303, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1, as published by the Free Software Foundation.
+
+ 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., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+
+ Sun Industry Standards Source License Version 1.1
+ =================================================
+ The contents of this file are subject to the Sun Industry Standards
+ Source License Version 1.1 (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.openoffice.org/license.html.
+
+ Software provided under this License is provided on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ See the License for the specific provisions governing your rights and
+ obligations concerning the Software.
+
+ The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+
+ Copyright © 2002 by Sun Microsystems, Inc.
+
+ All Rights Reserved.
+
+ Contributor(s): _______________________________________
+
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:office="http://openoffice.org/2000/office"
+ xmlns:style="http://openoffice.org/2000/style"
+ xmlns:text="http://openoffice.org/2000/text"
+ xmlns:table="http://openoffice.org/2000/table"
+ xmlns:draw="http://openoffice.org/2000/drawing"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:number="http://openoffice.org/2000/datastyle"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:chart="http://openoffice.org/2000/chart"
+ xmlns:dr3d="http://openoffice.org/2000/dr3d"
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:form="http://openoffice.org/2000/form"
+ xmlns:script="http://openoffice.org/2000/script"
+ office:class="text"
+ office:version="1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:meta="http://openoffice.org/2000/meta"
+ xmlns:config="http://openoffice.org/2001/config"
+ xmlns:help="http://openoffice.org/2000/help"
+ xmlns:xt="http://www.jclark.com/xt"
+ extension-element-prefixes="xt"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ exclude-result-prefixes="java">
+
+
+
+ <!-- ************ -->
+ <!-- *** body *** -->
+ <!-- ************ -->
+
+
+ <xsl:template match="/*/office:body">
+ <xsl:param name="collectedGlobalData"/>
+
+ <!-- isDebugMode-START: only isDebugMode purpose: shows the inlined style attributes of the temporary variable -->
+ <xsl:if test="$isDebugMode and not($outputType = 'CSS_HEADER')">
+ <xsl:element name="debug_tree_of_styles"><xsl:text>
+ </xsl:text><xsl:for-each select="$collectedGlobalData/allstyles/*">
+<xsl:text> </xsl:text><xsl:value-of select="name()"/><xsl:text> = </xsl:text><xsl:value-of select="."/><xsl:text>
+ </xsl:text>
+ </xsl:for-each>
+ </xsl:element>
+ </xsl:if>
+ <!-- isDebugMode-END -->
+
+
+ <!-- not using of 'apply-styles-and-content' as the content table information migth have been added to 'collectedGlobalData' variable -->
+ <xsl:apply-templates select="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name -->
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+
+
+ <!-- Usability feature, a link to the Content talbe above all level 1 header -->
+ <xsl:if test="$contentTableHeadings">
+ <xsl:call-template name="add-child-document-usability-links"/>
+ </xsl:if>
+
+
+ <xsl:choose>
+ <xsl:when test="not($outputType = 'WML') and not($outputType = 'PALM')">
+ <xsl:choose>
+ <!--If the input document is a global document and embed child documents (links) the transformation of the children will be started as well.
+ This is necessary as child documents do not know anything about their embedding into a global document. Chapters of childs
+ always start to count by zero instead of continously numbering.
+ For this, the chapter numbers of the current document (as a sequence of a global document) is dependent
+ of the number of chapter of the same level in preceding documents.
+ In case of multiple children, for usability reasons some linking is gonna be offered and the URLs of the content-table,
+ preceding and following file have to be given for the transformation.
+ -->
+ <xsl:when test="/*/@office:class='text-global' and /*/office:body/text:section/text:section-source/@xlink:href">
+ <!-- the children will be called later with a modified 'collectedGlobalData' variable -->
+ <xsl:call-template name="transform-global-document-and-children">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+
+
+
+ <!-- Usability feature, a link to the Content talbe above all level 1 header -->
+ <xsl:if test="$contentTableHeadings">
+ <xsl:call-template name="add-child-document-usability-links"/>
+ </xsl:if>
+
+
+ </xsl:template>
+
+
+
+
+ <!-- deactivating default template -->
+ <xsl:template match="*"/>
+
+
+ <!-- allowing all matched text nodes -->
+ <xsl:template match="text()">
+<!-- WML <xsl:value-of select="normalize-space(.)"/> -->
+ <xsl:value-of select="."/>
+ </xsl:template>
+
+
+
+ <!-- ################### -->
+ <!-- ### INLINE-TEXT ### -->
+ <!-- ################### -->
+
+
+ <!-- ****************** -->
+ <!-- *** Whitespace *** -->
+ <!-- ****************** -->
+
+
+ <xsl:template match="text:s">
+ <xsl:call-template name="write-breakable-whitespace">
+ <xsl:with-param name="whitespaces" select="@text:c"/>
+ </xsl:call-template>
+ </xsl:template>
+
+
+ <!--write the number of 'whitespaces' -->
+ <xsl:template name="write-breakable-whitespace">
+ <xsl:param name="whitespaces"/>
+
+ <!--write two space chars as the normal white space character will be stripped
+ and the other is able to break -->
+ <xsl:text> </xsl:text>
+ <xsl:if test="$whitespaces >= 2">
+ <xsl:call-template name="write-breakable-whitespace-2">
+ <xsl:with-param name="whitespaces" select="$whitespaces - 1"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+
+ <!--write the number of 'whitespaces' -->
+ <xsl:template name="write-breakable-whitespace-2">
+ <xsl:param name="whitespaces"/>
+ <!--write two space chars as the normal white space character will be stripped
+ and the other is able to break -->
+ <xsl:text> </xsl:text>
+ <xsl:if test="$whitespaces >= 2">
+ <xsl:call-template name="write-breakable-whitespace">
+ <xsl:with-param name="whitespaces" select="$whitespaces - 1"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+
+
+
+ <!-- *************** -->
+ <!-- *** Textbox *** -->
+ <!-- *************** -->
+
+ <xsl:template match="draw:text-box">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <!-- or -->
+ <!--+++++ HTML 4.0 INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER' or $outputType = 'CSS_INLINED'">
+ <xsl:element name="span">
+ <xsl:if test="@fo:min-height | @svg:width">
+ <xsl:attribute name="style">
+ <xsl:choose>
+ <xsl:when test="not(@svg:width)">
+ <xsl:text>height: </xsl:text><xsl:value-of select="@fo:min-height"/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test="not(@fo:min-height)">
+ <xsl:text>width: </xsl:text><xsl:value-of select="@svg:width"/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>height: </xsl:text><xsl:value-of select="@fo:min-height"/><xsl:text>; </xsl:text>
+ <xsl:text>width: </xsl:text><xsl:value-of select="@svg:width"/><xsl:text>; </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select="@draw:name"/>
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <!-- 2DO prove best usage for PALM -->
+ <!--+++++ PALM 3.2 SUBSET INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'PALM'">
+ <xsl:element name="span">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <!-- 2DO prove best usage for WML -->
+ <!--+++++ WML / WAP +++++-->
+ <xsl:otherwise>
+ <!-- no nested p tags in wml1.1 allowed -->
+ <xsl:choose>
+ <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- ID / NAME of text-box -->
+ <xsl:template match="@draw:name">
+
+ <xsl:attribute name="id">
+ <xsl:value-of select="."/>
+ </xsl:attribute>
+ </xsl:template>
+
+
+
+ <!-- ****************** -->
+ <!-- *** Paragraphs *** -->
+ <!-- ****************** -->
+
+ <xsl:template match="text:p | draw:page">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER'">
+ <xsl:element name="p">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ HTML 4.0 INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_INLINED'">
+ <xsl:element name="p">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <!--+++++ PALM 3.2 SUBSET INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'PALM'">
+ <xsl:choose>
+ <!-- in palm paragraphs children of text:list-items are better shown without 'p' tag-->
+ <xsl:when test="name(parent::*) = 'text:list-item'">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <!--+++++ WML / WAP +++++-->
+ <xsl:otherwise>
+ <!-- no nested p tags in wml1.1 allowed -->
+ <xsl:choose>
+ <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <!-- ***************** -->
+ <!-- *** Text Span *** -->
+ <!-- ***************** -->
+
+ <xsl:template match="text:span">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER'">
+ <xsl:element name="span">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ HTML 4.0 INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_INLINED'">
+ <xsl:element name="span">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <!--+++++ PALM 3.2 SUBSET INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'PALM'">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <!--+++++ WML / WAP +++++-->
+ <xsl:otherwise>
+ <!-- no nested p tags in wml1.1 allowed -->
+ <xsl:choose>
+ <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <!-- **************** -->
+ <!-- *** Headings *** -->
+ <!-- **************** -->
+
+ <xsl:template match="text:h">
+ <xsl:param name="collectedGlobalData"/>
+
+ <!-- Every heading element will get an unique anchor for its file, from its hiearchy level and name:
+ For example: The heading title 'My favorite heading' might get <a name="1+2+2+My+favorite+heading"/> -->
+ <xsl:choose>
+ <xsl:when test="$disableLinkedTableOfContent or $isJavaDisabled or not($outputType = 'CSS_HEADER')">
+ <!-- The URL linking of an table-of-content is due to a bug (cmp. bug id# 102311) not mapped as URL in the XML.
+ Linking of the table-of-content can therefore only be archieved by a work-around in HTML -->
+ <xsl:call-template name="create-heading">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- necessary as anchor for the content table -->
+ <xsl:call-template name="create-heading-anchor">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+
+ <!-- no embedding the orginal header, as an explicit anchor might be already set -->
+ <xsl:call-template name="create-heading">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- default matching for header elements -->
+ <xsl:template name="create-heading">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER'">
+
+ <xsl:variable name="headertyp" select="concat('h', @text:level)"/>
+ <xsl:element name="{$headertyp}">
+
+ <!-- outline style 'text:min-label-width' is interpreted as a CSS 'margin-left' attribute -->
+ <xsl:variable name="min-label" select="$office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/style:properties/@text:min-label-width"/>
+ <xsl:if test="$min-label">
+ <xsl:attribute name="style"><xsl:text>margin-left:</xsl:text><xsl:value-of select="$min-label"/><xsl:text>;</xsl:text></xsl:attribute>
+ </xsl:if>
+
+
+ <xsl:attribute name="class"><xsl:value-of select="translate(@text:style-name, '. %()/\', '')"/></xsl:attribute>
+
+ <!-- writing out a chapter number if desired (noticable when a corresponding 'text:outline-style' exist -->
+ <xsl:if test="string-length($office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@style:num-format) != 0">
+
+ <xsl:choose>
+ <xsl:when test="$disableLinkedTableOfContent or $isJavaDisabled or not($outputType = 'CSS_HEADER')">
+ <!-- the chapter number is the sum of 'text:start-value' and preceding siblings of 'text:h' with the same 'text:level',
+ furthermore when the current document is referenced by a global document - as part of a whole sequence of documents -,
+ the chapter no. is dependent of the amount of started headers in preceding documents.
+ If the 'text:start-value is not set the default value of '1' has to be taken. -->
+ <xsl:variable name="startValue" select="$office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@text:start-value"/>
+ <xsl:choose>
+ <xsl:when test="$startValue">
+ <xsl:choose>
+ <xsl:when test="@text:level='1'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel1
+ + $startValue"/>
+ </xsl:when>
+ <xsl:when test="@text:level='2'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel2
+ + $startValue"/>
+ </xsl:when>
+ <xsl:when test="@text:level='3'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel3
+ + $startValue"/>
+ </xsl:when>
+ <xsl:when test="@text:level='4'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel4
+ + $startValue"/>
+ </xsl:when>
+ <xsl:when test="@text:level='5'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel5
+ + $startValue"/>
+ </xsl:when>
+ <xsl:when test="@text:level='6'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel6
+ + $startValue"/>
+ </xsl:when>
+ <xsl:when test="@text:level='7'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel7
+ + $startValue"/>
+ </xsl:when>
+ <xsl:when test="@text:level='8'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel8
+ + $startValue"/>
+ </xsl:when>
+ <xsl:when test="@text:level='9'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel9
+ + $startValue"/>
+ </xsl:when>
+ <xsl:when test="@text:level='10'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel10
+ + $startValue"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="@text:level='1'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel1
+ + 1"/>
+ </xsl:when>
+ <xsl:when test="@text:level='2'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel2
+ + 1"/>
+ </xsl:when>
+ <xsl:when test="@text:level='3'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel3
+ + 1"/>
+ </xsl:when>
+ <xsl:when test="@text:level='4'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel4
+ + 1"/>
+ </xsl:when>
+ <xsl:when test="@text:level='5'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel5
+ + 1"/>
+ </xsl:when>
+ <xsl:when test="@text:level='6'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel6
+ + 1"/>
+ </xsl:when>
+ <xsl:when test="@text:level='7'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel7
+ + 1"/>
+ </xsl:when>
+ <xsl:when test="@text:level='8'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel8
+ + 1"/>
+ </xsl:when>
+ <xsl:when test="@text:level='9'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel9
+ + 1"/>
+ </xsl:when>
+ <xsl:when test="@text:level='10'">
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $precedingChapterLevel10
+ + 1"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="get-absolute-chapter-no">
+ <xsl:with-param name="precedingChapterLevel1" select="$precedingChapterLevel1"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>    </xsl:text>
+ </xsl:if>
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+
+ </xsl:element>
+ </xsl:when>
+
+
+ <!--+++++ HTML 4.0 INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_INLINED'">
+ <xsl:variable name="headertyp" select="concat('h', @text:level)"/>
+ <xsl:element name="{$headertyp}">
+
+ <xsl:apply-templates select="@text:style-name">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+
+ <!-- writing out a chapter number if desired (noticable when a corresponding 'text:outline-style' exist -->
+ <xsl:if test="$office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@text:style-name">
+
+ <!-- the chapter number is the sum of 'text:start-value' and preceding siblings of 'text:h' with the same 'text:level' -->
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@text:start-value"/>
+ <xsl:text>    </xsl:text>
+ </xsl:if>
+
+ </xsl:element>
+ </xsl:when>
+
+ <!-- 2DO: add Chapter No. for PALM and WML <-> problem nested apply-templates -->
+
+ <!--+++++ PALM 3.2 SUBSET INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'PALM'">
+ <xsl:variable name="headertyp" select="concat('h', @text:level)"/>
+ <xsl:element name="{$headertyp}">
+
+
+ <!-- All children content have to be nested in the styles (e.g. <i><b>ANY CONTENT</b></i>)
+ for this xsl:apply-templates will be called later / implicit -->
+ <xsl:call-template name="create-attribute-ALIGN">
+ <!-- getting the css styles for the style name (mapped by style-mapping.xsl) -->
+ <xsl:with-param name="styleProperties" select="$collectedGlobalData/allstyles/*[name()=current()/@text:style-name]"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ WML / WAP +++++-->
+ <xsl:otherwise>
+ <!-- no nested p tags in wml1.1 allowed -->
+ <xsl:choose>
+ <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
+ <!-- since no header styles exist, an emphasis is used -->
+ <xsl:element name="em">
+
+ <!-- writing out a chapter number if desired (noticable when a corresponding 'text:outline-style' exist -->
+ <xsl:if test="$office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@text:style-name">
+
+ <!-- the chapter number is the sum of 'text:start-value' and preceding siblings of 'text:h' with the same 'text:level' -->
+ <xsl:value-of select="count(preceding-sibling::text:h[@text:level = current()/@text:level])
+ + $office:styles/text:outline-style/text:outline-level-style[@text:level = current()/@text:level]/@text:start-value"/>
+ <xsl:text>    </xsl:text>
+ </xsl:if>
+
+ <xsl:apply-templates select="@text:style-name">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <!-- since no header styles exist, an emphasis is used -->
+ <xsl:element name="em">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <!-- ************* -->
+ <!-- *** Link *** -->
+ <!-- ************* -->
+
+ <xsl:template match="text:a | draw:a">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:call-template name="create-common-link">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:template>
+
+
+ <xsl:template name="create-common-link">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:choose>
+ <xsl:when test="not($outputType = 'WML')">
+ <xsl:element name="a">
+ <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
+ <!--<xsl:attribute name="class">ContentLink</xsl:attribute>-->
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- no nested p tags in wml1.1 allowed -->
+ <xsl:choose>
+ <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
+ <xsl:element name="a">
+ <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
+ <xsl:apply-templates select="descendant::text()"/>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <xsl:element name="a">
+ <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
+ <xsl:apply-templates select="descendant::text()"/>
+ </xsl:element>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+
+
+ <!-- ******************* -->
+ <!-- *** Image Link *** -->
+ <!-- ******************* -->
+
+ <xsl:template match="draw:image">
+ <xsl:param name="collectedGlobalData"/>
+
+ <!-- NO IMAGES SUPPLIED FOR WAP OR PALM -->
+ <xsl:if test="$outputType = 'CSS_HEADER' or $outputType = 'CSS_INLINED'">
+
+ <xsl:element name="img">
+ <xsl:if test="@svg:width">
+ <xsl:attribute name="width">
+ <xsl:call-template name="convert2pixel">
+ <xsl:with-param name="value" select="@svg:width"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="@svg:height">
+ <xsl:attribute name="height">
+ <xsl:call-template name="convert2pixel">
+ <xsl:with-param name="value" select="@svg:height"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:if test="svg:desc">
+ <xsl:attribute name="alt">
+ <xsl:value-of select="svg:desc"/>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:choose>
+ <!-- for images jared in open office document -->
+ <xsl:when test="contains(@xlink:href, '#Pictures/')">
+ <!-- creating an absolute http URL to the packed image file -->
+ <xsl:attribute name="src"><xsl:value-of select="concat($jaredRootURL, '/Pictures/', substring-after(@xlink:href, '#Pictures/'), $optionalURLSuffix)"/></xsl:attribute>
+ </xsl:when>
+<!-- Due to a XT bug no DOS ':' before DRIVE letter is allowed, it would result in a unkown protoco exception, but a file URL for a DOS
+ path needs the DRIVE letter, therefore all relative URLs remain relativ
+
+ <xsl:when test="contains(@xlink:href,'//') or (substring(@xlink:href,2,1) = ':') or starts-with(@xlink:href, '/')">
+ <xsl:attribute name="src"><xsl:value-of select="@xlink:href"/></xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <!~~ creating a absolute path/URL for the referenced resource ~~>
+ <xsl:attribute name="src"><xsl:value-of select="concat($absoluteSourceDirRef, @xlink:href, $optionalURLSuffix)"/></xsl:attribute>
+ </xsl:otherwise>
+-->
+ <xsl:otherwise>
+ <xsl:attribute name="src"><xsl:value-of select="@xlink:href"/></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ <!-- adding a line break to make the presentation more even with the OOo view -->
+ <xsl:element name="br"/>
+ </xsl:if>
+ </xsl:template>
+
+
+
+ <!-- ******************** -->
+ <!-- *** ordered list *** -->
+ <!-- ******************** -->
+
+ <xsl:template match="text:ordered-list">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER'">
+ <xsl:element name="ol">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <!--+++++ HTML 4.0 INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_INLINED'">
+ <xsl:element name="ol">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <!--+++++ PALM 3.2 SUBSET AND WAP INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'PALM'">
+ <xsl:element name="ol">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <!--+++++ WML / WAP +++++-->
+ <xsl:otherwise>
+ <xsl:choose>
+ <!-- simulating content break of capsulated list elements -->
+ <xsl:when test="ancestor::text:list-item">
+ <xsl:choose>
+ <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
+ <!-- simulating content break of capsulated list elements -->
+ <xsl:element name="br"></xsl:element>
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <!-- simulating content break of capsulated list elements -->
+ <xsl:element name="br"></xsl:element>
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <!-- ********************** -->
+ <!-- *** unordered list *** -->
+ <!-- ********************** -->
+
+ <xsl:template match="text:unordered-list">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER'">
+ <xsl:element name="ul">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ HTML 4.0 INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_INLINED'">
+ <xsl:element name="ul">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ PALM 3.2 SUBSET AND WAP INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'PALM'">
+ <xsl:element name="ul">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ WML / WAP +++++-->
+ <xsl:otherwise>
+ <xsl:choose>
+ <!-- simulating content break of capsulated list elements -->
+ <xsl:when test="ancestor::text:list-item">
+ <xsl:choose>
+ <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
+ <!-- simulating content break of capsulated list elements -->
+ <xsl:element name="br"></xsl:element>
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <!-- simulating content break of capsulated list elements -->
+ <xsl:element name="br"></xsl:element>
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <!-- ****************** -->
+ <!-- *** list item *** -->
+ <!-- ****************** -->
+
+ <xsl:template match="text:list-item">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER'">
+ <xsl:element name="li">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ HTML 4.0 INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_INLINED'">
+ <xsl:element name="li">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ PALM 3.2 SUBSET AND WAP INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'PALM'">
+ <xsl:element name="li">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ WML / WAP +++++-->
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
+ <!-- simulating list elements -->
+ <xsl:for-each select="ancestor::text:list-item">*</xsl:for-each>
+ <xsl:text>* </xsl:text>
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ <!-- list item break simulation (not in a table)-->
+ <xsl:if test="not(ancestor::table:table-cell) or following-sibling::text:list-item">
+ <xsl:element name="br"/>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <!-- simulating list elements -->
+ <xsl:for-each select="ancestor::text:list-item">*</xsl:for-each>
+ <xsl:text>* </xsl:text>
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ <!-- list item break simulation (not in a table)-->
+ <xsl:if test="not(ancestor::table:table-cell) or following-sibling::text:list-item">
+ <xsl:element name="br"/>
+ </xsl:if>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <!-- ********************************************** -->
+ <!-- *** Text Section (contains: draw:text-box) *** -->
+ <!-- ********************************************** -->
+
+ <xsl:template match="text:section">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:if test="not(contains(@text:display, 'none'))">
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER'">
+ <xsl:element name="span">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <!--+++++ HTML 4.0 INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_INLINED'">
+ <xsl:element name="span">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <!--+++++ PALM 3.2 SUBSET INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'PALM'">
+ <xsl:choose>
+ <xsl:when test="name(parent::*) = 'text:list-item'">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <!--+++++ WML / WAP +++++-->
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="not($outputType = 'WML')">
+ <xsl:element name="a">
+ <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- no nested p tags in wml1.1 allowed -->
+ <xsl:choose>
+ <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:template>
+
+
+
+ <xsl:template match="text:line-break">
+ <xsl:element name="br"/>
+ </xsl:template>
+
+
+<!--
+ TABHANDLING PROBLEM: Tabs are possible to be shown in the HTML text file, but will be later stripped as whitespaces.
+ To prevent this one way would be the PRE tag which unfortunately ALWAYS result into a line-break. No surrounding NOBR tags help.
+
+ <xsl:template match="text:tab-stop">
+ <xsl:if test="not(preceding-sibling::text:tab-stop)">
+ <xsl:element name="pre"><xsl:text>	</xsl:text><xsl:for-each select="following-sibling::text:tab-stop"><xsl:text>	</xsl:text></xsl:for-each></xsl:element>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="text:tab-stop"><xsl:text>	</xsl:text></xsl:template>
+-->
+ <!-- HOTFIX: 8 non-breakable-spaces instead of a TAB is a hack sometimes less Tabs are needed and the code more difficult to read -->
+ <xsl:template match="text:tab-stop">
+ <xsl:call-template name="write-breakable-whitespace">
+ <xsl:with-param name="whitespaces" select="8"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <!-- currently there have to be an explicit call of the style attribute nodes, maybe the attributes nodes have no priority only order relevant-->
+ <!-- STRANGE: checked with biorythm.sxc a simple xsl:apply-templates did not recognice the styles. Maybe caused by the template match order? -->
+ <xsl:template name="apply-styles-and-content">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:apply-templates select="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name -->
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+
+ <xsl:template match="@text:style-name | @draw:style-name | @draw:text-style-name | @table:style-name"><!-- | @presentation:style-name-->
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER'">
+ <xsl:attribute name="class"><xsl:value-of select="translate(., '. %()/\', '')"/></xsl:attribute>
+ </xsl:when>
+
+ <!--+++++ HTML 4.0 INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_INLINED'">
+ <xsl:attribute name="style"><xsl:value-of select="$collectedGlobalData/allstyles/*[name()=current()/.]"/></xsl:attribute>
+ </xsl:when>
+
+ <!--+++++ PALM 3.2 SUBSET INLINED WAY and WML / WAP +++++-->
+ <xsl:when test="$outputType = 'PALM' or $outputType = 'WML'">
+ <!-- getting the css styles for the style name (mapped by style-mapping.xsl) -->
+ <xsl:variable name="styleProperties" select="$collectedGlobalData/allstyles/*[name()=current()/.]"/>
+ <!-- changing the context node -->
+ <xsl:for-each select="parent::*">
+ <xsl:call-template name="create-nested-format-tags">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template match="text:sequence">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+
+</xsl:stylesheet>
--- /dev/null
+ <!--
+
+ The Contents of this file are made available subject to the terms of
+ either of the following licenses
+
+ - GNU Lesser General Public License Version 2.1
+ - Sun Industry Standards Source License Version 1.1
+
+ Sun Microsystems Inc., October, 2000
+
+ GNU Lesser General Public License Version 2.1
+ =============================================
+ Copyright 2000 by Sun Microsystems, Inc.
+ 901 San Antonio Road, Palo Alto, CA 94303, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1, as published by the Free Software Foundation.
+
+ 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., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+
+ Sun Industry Standards Source License Version 1.1
+ =================================================
+ The contents of this file are subject to the Sun Industry Standards
+ Source License Version 1.1 (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.openoffice.org/license.html.
+
+ Software provided under this License is provided on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ See the License for the specific provisions governing your rights and
+ obligations concerning the Software.
+
+ The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+
+ Copyright © 2002 by Sun Microsystems, Inc.
+
+ All Rights Reserved.
+
+ Contributor(s): _______________________________________
+
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:office="http://openoffice.org/2000/office"
+ xmlns:style="http://openoffice.org/2000/style"
+ xmlns:text="http://openoffice.org/2000/text"
+ xmlns:table="http://openoffice.org/2000/table"
+ xmlns:draw="http://openoffice.org/2000/drawing"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:number="http://openoffice.org/2000/datastyle"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:chart="http://openoffice.org/2000/chart"
+ xmlns:dr3d="http://openoffice.org/2000/dr3d"
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:form="http://openoffice.org/2000/form"
+ xmlns:script="http://openoffice.org/2000/script"
+ office:class="text"
+ office:version="1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:meta="http://openoffice.org/2000/meta"
+ xmlns:config="http://openoffice.org/2001/config"
+ xmlns:help="http://openoffice.org/2000/help"
+ xmlns:xt="http://www.jclark.com/xt"
+ extension-element-prefixes="xt"
+ xmlns:urlencoder="http://www.jclark.com/xt/java/java.net.URLEncoder"
+ xmlns:sxghelper="http://www.jclark.com/xt/java/com.sun.star.xslt.helper.SxgChildTransformer"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ exclude-result-prefixes="java">
+
+
+
+
+ <!-- ********************************************** -->
+ <!-- *** Global Document - Table of Content *** -->
+ <!-- ********************************************** -->
+
+
+
+ <xsl:template match="text:table-of-content">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+
+
+ <xsl:template match="text:index-body">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:apply-templates mode="content-table">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+
+
+ <xsl:template match="text:index-title" mode="content-table">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="text:reference-ref">
+ <xsl:param name="collectedGlobalData"/>
+
+ <!-- Java is needed as we have to encode the relative links (bug#102311) -->
+ <xsl:if test="not($isJavaDisabled)">
+ <xsl:element name="a">
+ <xsl:attribute name="href">
+ <xsl:text>#</xsl:text>
+ <xsl:call-template name="encode-string">
+ <!-- the space has to be normalized,
+ otherwise an illegal argument exception will be thrown for XT-->
+ <xsl:with-param name="textToBeEncoded" select="@text:ref-name"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+
+ </xsl:element>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="text:reference-mark">
+ <xsl:param name="collectedGlobalData"/>
+
+ <!-- Java is needed as we have to encode the relative links (bug#102311) -->
+ <xsl:if test="not($isJavaDisabled)">
+ <xsl:element name="a">
+ <xsl:attribute name="name">
+ <xsl:call-template name="encode-string">
+ <!-- the space has to be normalized,
+ otherwise an illegal argument exception will be thrown for XT-->
+ <xsl:with-param name="textToBeEncoded" select="@text:name"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+
+ </xsl:element>
+ </xsl:if>
+ </xsl:template>
+
+
+
+ <xsl:template match="text:reference-mark-start">
+ <xsl:param name="collectedGlobalData"/>
+
+ <!-- Java is needed as we have to encode the relative links (bug#102311) -->
+ <xsl:if test="not($isJavaDisabled)">
+ <xsl:element name="a">
+ <xsl:attribute name="name">
+ <xsl:call-template name="encode-string">
+ <!-- the space has to be normalized,
+ otherwise an illegal argument exception will be thrown for XT-->
+ <xsl:with-param name="textToBeEncoded" select="@text:name"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:variable name="endOfReference">
+ <xsl:for-each select="text:reference-mark-end[@name=current()/@text:name]">
+ <xsl:value-of select="position()"/>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:for-each select="following-sibling::*[position() < $endOfReference]">
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:for-each>
+ </xsl:element>
+ </xsl:if>
+ </xsl:template>
+
+
+
+
+ <!-- content table link -->
+ <xsl:template match="text:a" mode="content-table">
+ <xsl:param name="collectedGlobalData"/>
+
+
+ <!-- For anchors in content-headers a bug exists (cp. bug id# 102311) and they have to be worked out separately.
+ Currently the link used in the content-table of an Office XML (e.g. in the content table as '#7.Some%20Example%20Headline%7Outline')
+ is not a valid URL (cp. bug id# 102311). No file destination is specified nor exist any anchor element for these
+ links in the Office XML, nor is the chapter no. known in the linked files.
+ A workaround for this transformation therefore had to be made. This time-consuming mechanism is disabled by default and
+ can be activated by a parameter (i.e. 'disableLinkedTableOfContent'). A creation of an anchor is made for each header element.
+ All header titles gonna be encoding to be usable in a relative URL. -->
+ <xsl:choose>
+ <xsl:when test="$disableLinkedTableOfContent or $isJavaDisabled">
+ <xsl:call-template name="create-common-link">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="create-content-table-link">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <xsl:template name="get-absolute-chapter-no">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="precedingChapterLevel1"/>
+
+ <xsl:choose>
+ <xsl:when test="$globalDocumentRefToCurrentFile">
+
+ <xsl:variable name="currentFileHeadingNo">
+ <xsl:call-template name="get-current-file-heading-no"/>
+ </xsl:variable>
+ <xsl:variable name="testResult" select="$contentTableHeadings/heading[$globalDocumentRefToCurrentFile = @file-url][number($currentFileHeadingNo)]"/>
+
+ <xsl:call-template name="get-global-heading-no">
+ <xsl:with-param name="currentFileHeadingNo" select="translate($testResult/@absolute-chapter-level, '+', '.')"/>
+ <xsl:with-param name="precedingChapterLevel1" select="$precedingChapterLevel1"/>
+ </xsl:call-template>
+
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- When the chapter is in the global document itself the link has to be relative (e.g. #index) a absolute href does not
+ work with the browser. In case of chapter in the global document, the output URL of the global document was taken. -->
+ <xsl:variable name="currentFileHeadingNo">
+ <xsl:call-template name="get-current-file-heading-no"/>
+ </xsl:variable>
+ <xsl:variable name="testResult" select="$collectedGlobalData/content-table-headings/heading[$contentTableURL = @file-url][number($currentFileHeadingNo)]"/>
+
+ <xsl:call-template name="get-global-heading-no">
+ <xsl:with-param name="currentFileHeadingNo" select="translate($testResult/@absolute-chapter-level, '+', '.')"/>
+ <xsl:with-param name="precedingChapterLevel1" select="$precedingChapterLevel1"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template name="get-current-file-heading-no">
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:get-current-child-heading-no')">
+ <xsl:value-of select="sxghelper:get-current-child-heading-no()"/>
+ </xsl:when>
+ <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getCurrentChildHeadingNo')">
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.getCurrentChildHeadingNo()"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template name="get-next-current-file-heading-no">
+ <xsl:param name="file"/>
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:get-next-current-child-heading-no')">
+ <xsl:value-of select="sxghelper:get-next-current-child-heading-no($file)"/>
+ </xsl:when>
+ <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getNextCurrentChildHeadingNo')">
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.getNextCurrentChildHeadingNo($file)"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template name="get-global-heading-no">
+ <xsl:param name="currentFileHeadingNo"/>
+ <xsl:param name="precedingChapterLevel1"/>
+
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:get-global-heading-no')">
+ <xsl:value-of select="sxghelper:get-global-heading-no(string($currentFileHeadingNo), number($precedingChapterLevel1))"/>
+ </xsl:when>
+ <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getGlobalHeadingNo')">
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.getGlobalHeadingNo(string($currentFileHeadingNo), number($precedingChapterLevel1))"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+
+ <!-- necessary as anchor for the content table -->
+ <xsl:template name="create-heading-anchor">
+ <xsl:param name="collectedGlobalData"/>
+
+ <!--
+ Currently the link used in the Office XML (e.g. in the content table as '#7.Some%20Example%20Headline%7Outline')
+ is not a valid URL (cmp. bug id# 102311). No file destination is specified nor exist any anchor element for these
+ links in the Office XML.
+ Here we are creating an anchor with the space normalized text of this header as potential jump address of the content table -->
+
+ <xsl:choose>
+ <xsl:when test="$globalDocumentRefToCurrentFile">
+
+ <xsl:variable name="currentFileHeadingNo">
+ <xsl:call-template name="get-next-current-file-heading-no">
+ <xsl:with-param name="file" select="$globalDocumentRefToCurrentFile"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+
+ <xsl:variable name="testResult" select="$contentTableHeadings/heading[$globalDocumentRefToCurrentFile = @file-url][number($currentFileHeadingNo)]"/>
+ <xsl:if test="$isDebugMode">
+ <xsl:message>Matching child document header No. <xsl:value-of select="$currentFileHeadingNo"/></xsl:message>
+ <xsl:message>absolute-chapter-level: <xsl:value-of select="$testResult/@absolute-chapter-level"/></xsl:message>
+ <xsl:message>encodedTitle: <xsl:value-of select="$testResult/@encoded-title"/></xsl:message>
+ <xsl:message>globalDocumentRefToCurrentFile: <xsl:value-of select="$globalDocumentRefToCurrentFile"/></xsl:message>
+ <xsl:message>*** </xsl:message>
+ </xsl:if>
+
+ <xsl:element name="a">
+ <xsl:attribute name="name">
+ <xsl:value-of select="$testResult/@absolute-chapter-level"/>
+ <xsl:text>+</xsl:text>
+ <xsl:value-of select="$testResult/@encoded-title"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <!-- When the chapter is in the global document itself the link has to be relative (e.g. #index) a absolute href does not
+ work with the browser. In case of chapter in the global document, the output URL of the global document was taken. -->
+ <xsl:variable name="currentFileHeadingNo">
+ <xsl:call-template name="get-next-current-file-heading-no">
+ <xsl:with-param name="file" select="$contentTableURL"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+
+ <xsl:variable name="testResult" select="$collectedGlobalData/content-table-headings/heading[$contentTableURL = @file-url][number($currentFileHeadingNo)]"/>
+
+ <xsl:if test="$isDebugMode">
+ <xsl:message>Matching global document header No. <xsl:value-of select="$currentFileHeadingNo"/></xsl:message>
+ <xsl:message>absolute-chapter-level: <xsl:value-of select="$testResult/@absolute-chapter-level"/></xsl:message>
+ <xsl:message>encodedTitle: <xsl:value-of select="$testResult/@encoded-title"/></xsl:message>
+ <xsl:message>contentTableURL: <xsl:value-of select="$contentTableURL"/></xsl:message>
+ <xsl:message>*** </xsl:message>
+ </xsl:if>
+
+ <xsl:element name="a">
+ <xsl:attribute name="name">
+ <xsl:value-of select="$testResult/@absolute-chapter-level"/>
+ <xsl:text>+</xsl:text>
+ <xsl:value-of select="$testResult/@encoded-title"/>
+ </xsl:attribute>
+ </xsl:element>
+
+ </xsl:otherwise>
+ </xsl:choose>
+
+
+
+<!--
+
+ <xsl:variable name="title" select="normalize-space(.)"/>
+ <!~~DON'T WORK <xsl:variable name="title" select="normalize-space(descendant::text())"/> ~~>
+ <xsl:choose>
+ <xsl:when test="$globalDocumentRefToCurrentFile">
+ <xsl:variable name="testResults" select="$contentTableHeadings/heading[$globalDocumentRefToCurrentFile = @file-url][$title = @title][current()/@text:level = @level]"/>
+ <xsl:if test="1 < count($testResults)">
+ <xsl:message> *** CAUTION: Multiple chapter headings with similar names: </xsl:message>
+ <xsl:message> *** Title: <xsl:value-of select="$title"/> Level: <xsl:value-of select="@text:level"/></xsl:message>
+ </xsl:if>
+
+ <xsl:variable name="encodedTitle" select="$testResults/@encoded-title"/>
+ <xsl:choose>
+ <xsl:when test="$encodedTitle">
+ <xsl:element name="a">
+ <xsl:attribute name="name">
+ <xsl:value-of select="$encodedTitle"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <!~~ even when it is not ~~>
+ <xsl:variable name="newEncodedTitle">
+ <xsl:call-template name="encode-string">
+ <!~~ the space has to be normalized,
+ otherwise an illegal argument exception will be thrown for XT~~>
+ <xsl:with-param name="textToBeEncoded" select="$title"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:element name="a">
+ <xsl:attribute name="name">
+ <xsl:value-of select="$newEncodedTitle"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="testResults" select="$collectedGlobalData/content-table-headings/heading[$contentTableURL = @file-url][$title = @title][current()/@text:level = @level]"/>
+ <xsl:if test="1 < count($testResults)">
+ <xsl:message> *** CAUTION: Multiple chapter headings with similar names: </xsl:message>
+ <xsl:message> *** Title: <xsl:value-of select="$title"/> Level: <xsl:value-of select="@text:level"/></xsl:message>
+ <xsl:message> *** </xsl:message>
+ </xsl:if>
+
+ <xsl:variable name="encodedTitle" select="$testResults/@encoded-title"/>
+ <xsl:choose>
+ <xsl:when test="$encodedTitle">
+ <xsl:element name="a">
+ <xsl:attribute name="name">
+ <xsl:value-of select="$encodedTitle"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <!~~ even when it is not ~~>
+ <xsl:variable name="newEncodedTitle">
+ <xsl:call-template name="encode-string">
+ <!~~ the space has to be normalized,
+ otherwise an illegal argument exception will be thrown for XT~~>
+ <xsl:with-param name="textToBeEncoded" select="$title"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:element name="a">
+ <xsl:attribute name="name">
+ <xsl:value-of select="$newEncodedTitle"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+
+-->
+
+ </xsl:template>
+
+
+
+
+ <!-- ************************************** -->
+ <!-- CREATION OF A CONTENT TABLE LINK -->
+ <!-- ************************************** -->
+
+
+ <!-- a special behavior of text:a
+ (called from the 'text:a' template) -->
+
+ <xsl:template name="create-content-table-link">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:choose>
+ <xsl:when test="not($outputType = 'WML')">
+ <xsl:element name="a">
+ <xsl:attribute name="href">
+ <xsl:choose>
+ <xsl:when test="starts-with(@xlink:href, '#')">
+ <xsl:variable name="correctHeading" select="$collectedGlobalData/content-table-headings/heading[current()/@xlink:href = @content-table-id]"/>
+
+ <xsl:value-of select="$correctHeading/@out-file-url"/>
+ <xsl:text>#</xsl:text>
+ <xsl:value-of select="$correctHeading/@absolute-chapter-level"/>
+ <xsl:text>+</xsl:text>
+ <xsl:value-of select="$correctHeading/@encoded-title"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="create-common-link">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <xsl:call-template name="apply-styles-and-content">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- 2DO: currently no WML support
+
+ <!~~ no nested p tags in wml1.1 allowed ~~>
+ <xsl:choose>
+ <xsl:when test="ancestor::*[contains($wap-paragraph-elements, name())]">
+ <xsl:element name="a">
+ <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
+ <xsl:apply-templates select="."/>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="p">
+ <xsl:element name="a">
+ <xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute>
+ <xsl:apply-templates select="."/>
+ </xsl:element>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose> -->
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!--
+ CREATION OF A HELPER VARIABLE AS WORKAROUND FOR THE CONTENT TABLE ULR BUG
+
+
+ As no valid URL from the content table to the child documents exist in the content table,
+ a work-around is done:
+
+ First two helper variables are being created.
+
+ One containing the list of all references of the global document:
+ containg all their title,
+ for example:
+
+ <chapter-ref title="aTitle 1"/>
+ <chapter-ref title="aTitle 2"/>
+ <chapter-ref title="aTitle 2/>
+ <chapter-ref title="aTitle 3/>
+
+ The other containing all heading from the child documents linked from the global document.
+ The variable 'childrenHeadings' contains their title and the number of preceding similar titles,
+ for example:
+
+
+ <child file-url="aURL">
+ <heading title="aTitle1" level="1">
+ <heading title="aTitle2" level="2">
+ <heading title="aTitle3" level="1">
+ </child>
+
+ For each chapter reference from the content table the
+
+ by encoding the chapter names of the child document with the java URLEncoder and
+ use this as a part of a link. Furthermore for all heading elements a encoded anchor will be created from the heading.
+ Last the workaround parses all children documents for this anhor, as there is no distinction of files from the content table entries.
+
+ The new added node set to the collectedGlobalData variable concering the content table is written as
+
+
+ <content-table-headings content-table-url="aURL_ToTheGeneratedContentTable">
+ <heading file-url="aFileURLToTheGeneratedHeading1" level="1">
+ <heading file-url="aFileURLToTheGeneratedHeading2" level="2">
+ <heading file-url="aFileURLToTheGeneratedHeading1" level="1">
+ <heading file-url="aFileURLToTheGeneratedHeading2" level="2">
+ </content-table-headings>
+
+
+ Preconditions:
+ The correct sequence of child documents according to the Content Table is necessary, granted by the office.
+ -->
+ <xsl:template name="Create-helper-variables-for-Content-Table">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:if test="$isDebugMode"><xsl:message>Creation of global document helper variable for the content table....</xsl:message></xsl:if>
+
+ <!-- Here a helper variable of the content table is created, of all chapter-references which point to a child document.
+ an 'chapter-ref' element will be created, containg their title and the number of preceding similar titles,
+ for example:
+
+ <chapter-ref title="aTitle 1"/>
+ <chapter-ref title="aTitle 2"/>
+ <chapter-ref title="aTitle 2"/>
+ <chapter-ref title="aTitle 3"/>
+ -->
+ <xsl:variable name="chapterRefs-RTF">
+ <!-- '/*/' as the flat and the zipped XML file format have different root elements -->
+ <xsl:for-each select="/*/office:body/text:table-of-content/text:index-body/text:p/text:a">
+ <xsl:variable name="currentTitle" select="normalize-space(string(.))"/>
+ <xsl:element name="chapter-ref">
+ <xsl:attribute name="title">
+ <xsl:value-of select="$currentTitle"/>
+ </xsl:attribute>
+ <xsl:attribute name="content-table-id">
+ <xsl:value-of select="@xlink:href"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:if test="$isDebugMode"><xsl:message>Finished the Creation of global document helper variable for the content table!</xsl:message></xsl:if>
+
+
+
+
+ <xsl:if test="$isDebugMode"><xsl:message>Creation of global document helper variable for the child documents....</xsl:message></xsl:if>
+ <!-- Here a helper variable of created from the children documents.
+ Containg all heading elements from the child documents. Some or all of them are
+ chapters referenced by the Global Document.
+ The variable contains their title, the level of the heading and the file URL of the child,
+ for example:
+
+ <heading title="aTitle1" level="1" file-url="aURL1">
+ <heading title="aTitle2" level="2" file-url="aURL1">
+ <heading title="aTitle3" level="1" file-url="aURL1">
+ <heading title="aTitle4" level="1" file-url="aURL2">
+ <heading title="aTitle5" level="2" file-url="aURL2">
+ <heading title="aTitle2" level="3" file-url="aURL2">
+ <heading title="aTitle6" level="3" file-url="aURL2">
+ <heading-count>7</heading-count>
+ -->
+ <xsl:variable name="childrenHeadings-RTF">
+ <!-- all headers from children documents will be added -->
+ <xsl:apply-templates select="/*/office:body/text:section" mode="creation-of-variable"/>
+ </xsl:variable>
+ <xsl:if test="$isDebugMode"><xsl:message>Finished the Creation of global document helper variable for the child documents!</xsl:message></xsl:if>
+
+
+ <xsl:choose>
+ <xsl:when test="function-available('xt:node-set')">
+ <xsl:call-template name="Create-global-variable-for-Content-Table">
+ <xsl:with-param name="chapterRefs" select="xt:node-set($chapterRefs-RTF)"/>
+ <xsl:with-param name="childrenHeadings" select="xt:node-set($childrenHeadings-RTF)"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="function-available('xalan:nodeset')">
+ <xsl:call-template name="Create-global-variable-for-Content-Table">
+ <xsl:with-param name="chapterRefs" select="xalan:nodeset($chapterRefs-RTF)"/>
+ <xsl:with-param name="childrenHeadings" select="xalan:nodeset($childrenHeadings-RTF)"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+
+ <xsl:template name="Create-global-variable-for-Content-Table">
+ <xsl:param name="chapterRefs"/>
+ <xsl:param name="childrenHeadings"/>
+ <xsl:param name="collectedGlobalData"/>
+
+
+ <xsl:if test="$isDebugMode">
+ <!-- helper variable collecting all headings from the global document file children-->
+ <xsl:for-each select="$childrenHeadings/heading">
+ <xsl:message># <xsl:value-of select="position()"/></xsl:message>
+ <xsl:message>level: <xsl:value-of select="@level"/></xsl:message>
+ <xsl:message>title: <xsl:value-of select="@title"/></xsl:message>
+ <xsl:message>encoded-title: <xsl:value-of select="@encoded-title"/></xsl:message>
+ <xsl:message>file-url: <xsl:value-of select="@file-url"/></xsl:message>
+ <xsl:message>header-no: <xsl:value-of select="@header-no"/></xsl:message>
+ <xsl:message>**</xsl:message>
+ </xsl:for-each>
+ <xsl:message>**</xsl:message>
+ <xsl:message>**</xsl:message>
+
+ <!-- helper variable collecting all heading references from the content table of the the global document -->
+ <xsl:message>childrenHeadings/heading-count: <xsl:value-of select="$childrenHeadings/heading-count"/></xsl:message>
+ <xsl:for-each select="$chapterRefs/chapter-ref">
+ <xsl:message># <xsl:value-of select="position()"/></xsl:message>
+ <xsl:message>title: <xsl:value-of select="@title"/></xsl:message>
+ <xsl:message>**</xsl:message>
+ </xsl:for-each>
+ </xsl:if>
+
+
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:set-heading-no')">
+ <xsl:value-of select="sxghelper:set-heading-no(1)"/>
+ <xsl:value-of select="sxghelper:set-current-child-no(1)"/>
+ <xsl:value-of select="sxghelper:set-current-child-url(string($childrenHeadings/heading/@file-url))"/>
+ </xsl:when>
+ <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.setHeadingNo')">
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setHeadingNo(1)"/>
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setCurrentChildNo(1)"/>
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setCurrentChildUrl(string($childrenHeadings/heading/@file-ur))"/>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:if test="$isDebugMode"><xsl:message>Creating global document variable for chapter relations....</xsl:message></xsl:if>
+ <xsl:variable name="contentTableHeadingsGlobalData-RTF">
+ <xsl:element name="content-table-headings">
+ <!-- all headings are linked from the current global document input file -->
+ <xsl:attribute name="content-table-url">
+ <xsl:value-of select="$contentTableURL"/>
+ </xsl:attribute>
+
+ <!-- had to use a for loop, as a recursion ends with an stackoverflow exception after about 600 recursive calls -->
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:get-heading-no')">
+ <xsl:for-each select="$chapterRefs/chapter-ref">
+ <xsl:call-template name="searchHeadingInChildDocument">
+ <xsl:with-param name="chapterRefs" select="$chapterRefs"/>
+ <xsl:with-param name="childrenHeadings" select="$childrenHeadings"/>
+ <xsl:with-param name="currentChapterRefNo" select="position()"/>
+ <xsl:with-param name="currentHeadingNo" select="sxghelper:get-heading-no()"/>
+ <xsl:with-param name="currentChildURL" select="sxghelper:get-current-child-url()"/>
+ <xsl:with-param name="currentChildNo" select="sxghelper:get-current-child-no()"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getHeadingNo')">
+ <xsl:for-each select="$chapterRefs/chapter-ref">
+ <xsl:call-template name="searchHeadingInChildDocument">
+ <xsl:with-param name="chapterRefs" select="$chapterRefs"/>
+ <xsl:with-param name="childrenHeadings" select="$childrenHeadings"/>
+ <xsl:with-param name="currentChapterRefNo" select="position()"/>
+ <xsl:with-param name="currentHeadingNo" select="java:com.sun.star.xslt.helper.SxgChildTransformer.getHeadingNo()"/>
+ <xsl:with-param name="currentChildURL" select="java:com.sun.star.xslt.helper.SxgChildTransformer.getCurrentChildUrl()"/>
+ <xsl:with-param name="currentChildNo" select="java:com.sun.star.xslt.helper.SxgChildTransformer.getCurrentChildNo()"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:element>
+
+ <!-- adding the already exisiting global data environment -->
+ <xsl:copy-of select="$collectedGlobalData"/>
+ </xsl:variable>
+ <xsl:if test="$isDebugMode"><xsl:message>Finished global document variable for chapter relations!</xsl:message></xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="function-available('xt:node-set')">
+ <xsl:call-template name="start-self-and-children-transformation">
+ <xsl:with-param name="collectedGlobalData" select="xt:node-set($contentTableHeadingsGlobalData-RTF)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="function-available('xalan:nodeset')">
+ <xsl:call-template name="start-self-and-children-transformation">
+ <xsl:with-param name="collectedGlobalData" select="xalan:nodeset($contentTableHeadingsGlobalData-RTF)"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template name="searchHeadingInChildDocument">
+ <xsl:param name="chapterRefs"/>
+ <xsl:param name="childrenHeadings"/>
+ <xsl:param name="currentChapterRefNo"/>
+ <xsl:param name="currentHeadingNo"/>
+ <xsl:param name="currentChildURL"/>
+ <xsl:param name="currentChildNo"/>
+
+
+ <xsl:variable name="currentChapterRef" select="$chapterRefs/chapter-ref[$currentChapterRefNo]"/>
+ <xsl:variable name="currentChapterID" select="$currentChapterRef/@content-table-id"/>
+ <xsl:variable name="currentChapterTitle" select="$currentChapterRef/@title"/>
+
+ <xsl:variable name="currentChildHeading" select="$childrenHeadings/heading[$currentHeadingNo]"/>
+ <xsl:variable name="headingTitle" select="$currentChildHeading/@title"/>
+ <xsl:variable name="headingLevel" select="$currentChildHeading/@level"/>
+ <xsl:variable name="headingNo" select="$currentChildHeading/@header-no"/>
+ <xsl:variable name="newChildURL" select="$currentChildHeading/@file-url"/>
+
+ <xsl:if test="$isDebugMode">
+ <xsl:message>*** new heading </xsl:message>
+ <xsl:message>currentChapterID: <xsl:value-of select="$currentChapterID"/></xsl:message>
+ <xsl:message>currentChapterTitle: <xsl:value-of select="$currentChapterTitle"/></xsl:message>
+ <xsl:message>currentChapterID: <xsl:value-of select="$currentChapterID"/></xsl:message>
+ <xsl:message>currentHeadingNo: <xsl:value-of select="$currentHeadingNo"/></xsl:message>
+ <xsl:message>headingTitle: <xsl:value-of select="$headingTitle"/></xsl:message>
+ <xsl:message>headingLevel: <xsl:value-of select="$headingLevel"/></xsl:message>
+ <xsl:message>headingNo: <xsl:value-of select="$headingNo"/></xsl:message>
+ <xsl:message>newChildURL: <xsl:value-of select="$newChildURL"/></xsl:message>
+ </xsl:if>
+
+ <xsl:variable name="outFileURL">
+ <xsl:choose>
+ <xsl:when test="substring-before($newChildURL,'.xml')">
+ <xsl:value-of select="concat(substring-before($newChildURL,'.xml'),'.htm')"/>
+ </xsl:when>
+ <xsl:when test="substring-before($newChildURL,'.sx')">
+ <xsl:value-of select="concat(substring-before($newChildURL,'.sx'),'.htm')"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="isChapterHeading" select="$headingTitle = $currentChapterTitle"/>
+ <xsl:variable name="isNewFile" select="string($newChildURL) != string($currentChildURL)"/>
+
+
+
+
+ <xsl:if test="$isNewFile">
+ <!-- reset of the already collected child headers -->
+ <xsl:call-template name="calc-chapter-numbers">
+ <xsl:with-param name="level" select="0"/>
+ </xsl:call-template>
+ </xsl:if>
+ <xsl:variable name="absoluteChapterLevel">
+ <xsl:call-template name="calc-chapter-numbers">
+ <xsl:with-param name="level" select="number($headingLevel)"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+
+ <xsl:element name="heading">
+ <!-- necessary to as ID from the content table to get the correct heading element (the buggy URL used as ID)-->
+ <xsl:attribute name="content-table-id">
+ <xsl:choose>
+ <xsl:when test="$isChapterHeading">
+ <xsl:value-of select="$currentChapterID"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>only a heading, but not a chapter</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <!-- no of the used child, necessary for quick finding of chapters of next file -->
+ <xsl:attribute name="child-document-no">
+ <xsl:choose>
+ <xsl:when test="$isNewFile">
+ <xsl:value-of select="$currentChildNo + 1"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$currentChildNo"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <!-- the URL of the child document source, containing the heading -->
+ <xsl:attribute name="file-url">
+ <xsl:value-of select="$newChildURL"/>
+ </xsl:attribute>
+ <xsl:attribute name="out-file-url">
+ <xsl:value-of select="$outFileURL"/>
+ </xsl:attribute>
+ <xsl:attribute name="level">
+ <xsl:value-of select="$headingLevel"/>
+ </xsl:attribute>
+ <xsl:attribute name="title">
+ <xsl:value-of select="$headingTitle"/>
+ </xsl:attribute>
+ <xsl:attribute name="encoded-title">
+ <xsl:value-of select="$currentChildHeading/@encoded-title"/>
+ </xsl:attribute>
+ <xsl:attribute name="absolute-chapter-level">
+ <xsl:value-of select="$absoluteChapterLevel"/>
+ </xsl:attribute>
+ </xsl:element>
+
+
+ <xsl:choose>
+ <xsl:when test="$childrenHeadings/heading-count != $currentHeadingNo">
+ <!-- procede as long the list of children isn'nt worked through -->
+ <xsl:choose>
+ <xsl:when test="$isChapterHeading">
+ <!-- global variables have to be set, so the for-each loop can access them -->
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:set-heading-no')">
+ <xsl:value-of select="sxghelper:set-heading-no($currentHeadingNo + 1)"/>
+ <xsl:if test="$isNewFile">
+ <xsl:value-of select="sxghelper:set-current-child-no($currentChildNo + 1)"/>
+ <xsl:value-of select="sxghelper:set-current-child-url(string($newChildURL))"/>
+ </xsl:if>
+ </xsl:when>
+ <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.setHeadingNo')">
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setHeadingNo($currentHeadingNo + 1)"/>
+ <xsl:if test="$isNewFile">
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setCurrentChildNo($currentChildNo + 1)"/>
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.setCurrentChildUrl($newChildURL)"/>
+ </xsl:if>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- not a chapter heading, call itself until a chapter ref is found or the end of headings is reached -->
+ <xsl:call-template name="searchHeadingInChildDocument">
+ <xsl:with-param name="chapterRefs" select="$chapterRefs"/>
+ <xsl:with-param name="childrenHeadings" select="$childrenHeadings"/>
+ <xsl:with-param name="currentChapterRefNo" select="$currentChapterRefNo"/>
+ <xsl:with-param name="currentHeadingNo" select="$currentHeadingNo + 1"/>
+ <xsl:with-param name="currentChildURL" select="$currentChildURL"/>
+ <xsl:with-param name="currentChildNo" select="$currentChildNo"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="$isDebugMode">
+ <xsl:message>All child documents have been walked through without finding the chapter name!</xsl:message>
+ <xsl:message> childrenHeadings/heading-count: <xsl:value-of select="$childrenHeadings/heading-count"/></xsl:message>
+ <xsl:message> currentHeadingNo: <xsl:value-of select="$currentHeadingNo"/></xsl:message>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+
+
+ <!-- Chapters from the Content Table have currently no anchor to child documents in OOo XML.
+ As solution, whenever a a global document every header of the HTML output gets get's an anchor in the Therefore-->
+ <xsl:template name="encode-string">
+ <xsl:param name="encoding" select="'UTF-8'"/>
+ <xsl:param name="textToBeEncoded"/>
+
+ <xsl:choose>
+ <xsl:when test="function-available('urlencoder:encode')">
+ <xsl:value-of select="urlencoder:encode(normalize-space($textToBeEncoded),$encoding)"/>
+ </xsl:when>
+ <xsl:when test="function-available('java:java.net.URLEncoder.encode')">
+ <xsl:value-of select="java:java.net.URLEncoder.encode(string(normalize-space($textToBeEncoded)),string($encoding))"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+
+
+ <!-- ******************************************************************************************************** -->
+ <!-- *** TRANSFORMATION OF ALL CHILD DOCUMENTS OF THE GLOBAL DOCUMENTS BY USING A EXTERNAL HELPER CLASS *** -->
+ <!-- ******************************************************************************************************** -->
+
+
+ <!-- a new element 'contentTableHeadings' will be added to the helper variable the first time a child will be transformed -->
+ <xsl:template name="transform-global-document-and-children">
+ <xsl:param name="collectedGlobalData"/>
+
+
+ <xsl:choose>
+ <xsl:when test="$collectedGlobalData/content-table-headings">
+ <xsl:call-template name="start-child-transformation">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- The necessary auxiliary variable hasn't build yet.
+ This variable gonna store all headers (with chapter numbers) and the URL of their files -->
+
+ <xsl:call-template name="Create-helper-variables-for-Content-Table">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <xsl:template name="start-self-and-children-transformation">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:if test="$isDebugMode">
+ <xsl:call-template name="debug-content-table-headings-variable">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+
+ <xsl:message>Parsing the global document...</xsl:message>
+ </xsl:if>
+
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+
+
+ <xsl:if test="$isDebugMode"><xsl:message>Parsing the child documents...</xsl:message></xsl:if>
+ <xsl:call-template name="start-child-transformation">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+
+ </xsl:template>
+
+
+
+
+ <xsl:template name="start-child-transformation">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:if test="$isDebugMode"><xsl:message>Starting the child transformations...</xsl:message></xsl:if>
+
+ <!-- As the childs of a global document (with suffix .sxg) do not know anything about their global parent,
+ the transformation of global documents children have to be done implizit.
+ Otherwise the chapter number of the children will always start with zero, as they do not know anything about the
+ proceding chapters.
+ Furthermore, they don't have any links about preceeding and following documents and no linking for usability reasons
+ could be done. Therefore the children have to be transformed during the transformation of a global (sxg) document -->
+ <xsl:if test="$isDebugMode">
+ <xsl:choose>
+ <xsl:when test="$collectedGlobalData/content-table-headings">
+ <xsl:message>Contentable data exists as global data!</xsl:message>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>No Contentable global data exists!</xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <!-- currently this function only works with node-sets from XT -->
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:transform-children')">
+ <xsl:message>
+ <xsl:value-of select="sxghelper:transform-children( $collectedGlobalData/content-table-headings,
+ string($jaredRootURL),
+ string($absoluteSourceDirRef),
+ string($optionalURLSuffix),
+ string($dpi),
+ string($outputType),
+ $isDebugMode)"/>
+ </xsl:message>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>Java method transformChildren to transform all children of a global document could not be found. Be sure to use the XT processor.</xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+
+
+ <!-- ******************************************************************************* -->
+ <!-- *** Creation of helper variable of the headings of all children documents *** -->
+ <!-- ******************************************************************************* -->
+
+
+ <xsl:template match="/*/office:body/text:section" mode="creation-of-variable">
+ <xsl:call-template name="getChildRootNode"/>
+
+ <!-- after the last child document the global document will be parsed -->
+ <xsl:if test="position() = last()">
+ <!-- search the global document after all child documents have been searched
+
+ODK PATCH NO INDEX ELEMENT WANTED !! - null pointer exception
+ <xsl:call-template name="getPreviousHeaderNo">
+ <xsl:with-param name="fileURL" select="$contentTableURL"/>
+ <xsl:with-param name="amountOfCurrentHeading" select="count(following-sibling::text:h)"/>
+ <xsl:with-param name="nodeToSearchForHeading" select="following-sibling::text:h"/>
+ </xsl:call-template>
+-->
+ <!-- get the overall No of Headers -->
+ <xsl:call-template name="getAllHeaderNo"/>
+ </xsl:if>
+ </xsl:template>
+
+
+ <xsl:template name="getChildRootNode">
+ <xsl:variable name="fileURL" select="text:section-source/@xlink:href"/>
+
+ <xsl:choose>
+ <!-- if absolute URL or absolute DOS PATH or absolute Unix path -->
+ <xsl:when test="contains($fileURL,'//') or (substring($fileURL,2,1) = ':') or starts-with($fileURL, '/')">
+ <xsl:variable name="childRootNode" select="document($fileURL)"/>
+ <xsl:call-template name="getPreviousHeaderNo">
+ <xsl:with-param name="fileURL" select="$fileURL"/>
+ <!-- NO absolute source path will be added as prefix -->
+ <xsl:with-param name="amountOfCurrentHeading" select="count($childRootNode/*/office:body/descendant::text:h)"/>
+ <xsl:with-param name="nodeToSearchForHeading" select="$childRootNode/*/office:body/descendant::text:h"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="childRootNode" select="document(concat($absoluteSourceDirRef,'/',$fileURL))"/>
+ <xsl:call-template name="getPreviousHeaderNo">
+ <xsl:with-param name="fileURL" select="$fileURL"/>
+ <!-- the absolute source path will be added as prefix -->
+ <xsl:with-param name="amountOfCurrentHeading" select="count($childRootNode/*/office:body/descendant::text:h)"/>
+ <xsl:with-param name="nodeToSearchForHeading" select="$childRootNode/*/office:body/descendant::text:h"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template name="getPreviousHeaderNo">
+ <xsl:param name="fileURL"/>
+ <xsl:param name="nodeToSearchForHeading"/>
+ <xsl:param name="amountOfCurrentHeading"/>
+
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:get-previous-child-documents-heading-count')">
+ <xsl:call-template name="addHeadingInfo">
+ <xsl:with-param name="nodeToSearchForHeading" select="$nodeToSearchForHeading"/>
+ <xsl:with-param name="fileURL" select="$fileURL"/>
+ <xsl:with-param name="previousHeader" select="sxghelper:get-previous-child-documents-heading-count($amountOfCurrentHeading)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getPreviousChildDocumentsHeadingCount')">
+ <xsl:call-template name="addHeadingInfo">
+ <xsl:with-param name="nodeToSearchForHeading" select="$nodeToSearchForHeading"/>
+ <xsl:with-param name="fileURL" select="$fileURL"/>
+ <xsl:with-param name="previousHeader" select="java:com.sun.star.xslt.helper.SxgChildTransformer.getPreviousChildDocumentsHeadingCount($amountOfCurrentHeading)"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+
+ </xsl:template>
+
+
+ <xsl:template name="addHeadingInfo">
+ <xsl:param name="fileURL"/>
+ <xsl:param name="previousHeader"/>
+ <xsl:param name="nodeToSearchForHeading"/>
+
+ <xsl:variable name="previousHeader2" select="number($previousHeader)"/>
+ <xsl:for-each select="$nodeToSearchForHeading">
+
+ <xsl:variable name="title" select="normalize-space(.)"/>
+
+ <xsl:variable name="encodedTitle">
+ <xsl:call-template name="encode-string">
+ <!-- the space has to be normalized,
+ otherwise an illegal argument exception will be thrown for XT-->
+ <xsl:with-param name="textToBeEncoded" select="$title"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:element name="heading">
+ <!-- odd but 'descendant:text()' didn't work, but '.', to get all text nodes of the header -->
+ <xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
+ <xsl:attribute name="encoded-title"><xsl:value-of select="$encodedTitle"/></xsl:attribute>
+ <xsl:attribute name="level"><xsl:value-of select="@text:level"/></xsl:attribute>
+ <xsl:attribute name="file-url"><xsl:value-of select="$fileURL"/></xsl:attribute>
+ <xsl:attribute name="header-no"><xsl:value-of select="position() + $previousHeader2"/></xsl:attribute>
+ </xsl:element>
+ </xsl:for-each>
+
+ </xsl:template>
+
+
+ <xsl:template name="getAllHeaderNo">
+
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:get-all-child-documents-heading-count')">
+ <xsl:call-template name="addAllHeaderNoElement">
+ <xsl:with-param name="allHeader" select="sxghelper:get-all-child-documents-heading-count()"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getAllChildDocumentsHeadingCount')">
+ <xsl:call-template name="addAllHeaderNoElement">
+ <xsl:with-param name="allHeader" select="java:com.sun.star.xslt.helper.SxgChildTransformer.getAllChildDocumentsHeadingCount()"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="addAllHeaderNoElement">
+ <xsl:param name="allHeader"/>
+
+ <xsl:element name="heading-count">
+ <xsl:value-of select="$allHeader"/>
+ </xsl:element>
+
+ </xsl:template>
+
+
+ <!-- ******************************************************************************************************* -->
+ <!-- *** Creation of a line of links at the beginning and end of a child document to enhance usability *** -->
+ <!-- ******************************************************************************************************* -->
+
+ <xsl:template name="add-child-document-usability-links">
+ <xsl:element name="center">
+ <xsl:element name="small">
+ <xsl:text>[ </xsl:text>
+
+
+ <xsl:variable name="globalDocumentDir" select="sxghelper:get-global-document-dir()"/>
+ <xsl:variable name="currentChildNo" select="number($contentTableHeadings/heading[$globalDocumentRefToCurrentFile = @file-url]/@child-document-no)"/>
+ <xsl:variable name="earlierDocURL" select="$contentTableHeadings/heading[($currentChildNo - 1) = @child-document-no]/@out-file-url"/>
+<!--
+<xsl:message>from: <xsl:value-of select="$globalDocumentRefToCurrentFile"/></xsl:message>
+<xsl:message>to: <xsl:value-of select="$earlierDocURL"/></xsl:message>
+<xsl:message>Is: <xsl:call-template name="get-relative-file-ref">
+ <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
+ <xsl:with-param name="targetFileRef" select="$earlierDocURL"/>
+ </xsl:call-template>
+</xsl:message>-->
+
+
+ <xsl:if test="$earlierDocURL">
+ <xsl:element name="a">
+ <xsl:attribute name="href">
+ <!-- when the links starts with a '#' it's a link to the Content Table-->
+ <xsl:choose>
+ <xsl:when test="starts-with($earlierDocURL, '#')">
+
+ <xsl:call-template name="get-relative-file-ref">
+ <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
+ <xsl:with-param name="targetFileRef" select="."/>
+ </xsl:call-template>
+<!-- <xsl:value-of select="concat($contentTableURL, $earlierDocURL)"/>-->
+ </xsl:when>
+ <xsl:otherwise>
+
+ <xsl:call-template name="get-relative-file-ref">
+ <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
+ <xsl:with-param name="targetFileRef" select="$earlierDocURL"/>
+ </xsl:call-template>
+<!--
+
+ <xsl:value-of select="concat($globalDocumentDir, $earlierDocURL)"/>-->
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:text>Previous document</xsl:text>
+ </xsl:element>
+
+ <xsl:text> | </xsl:text>
+ </xsl:if>
+
+ <xsl:element name="a">
+ <xsl:attribute name="href">
+ <!-- when globalDocumentRefToCurrentFile is unset the current file is the Content Table-->
+ <xsl:choose>
+ <xsl:when test="$globalDocumentRefToCurrentFile">
+ <xsl:variable name="contentTableDir">
+ <xsl:call-template name="get-name-of-table-of-content-document"/>
+ </xsl:variable>
+
+ <xsl:call-template name="get-relative-file-ref">
+ <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
+ <xsl:with-param name="targetFileRef" select="$contentTableDir"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>#</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+
+<!-- <xsl:value-of select="$contentTableURL"/>-->
+ </xsl:attribute>
+ <xsl:text>Content Table</xsl:text>
+ </xsl:element>
+
+
+ <xsl:variable name="nextDocURL" select="$contentTableHeadings/heading[($currentChildNo + 1) = @child-document-no]/@out-file-url"/>
+ <xsl:if test="$nextDocURL">
+ <xsl:text> | </xsl:text>
+ <xsl:element name="a">
+ <xsl:attribute name="href">
+ <!-- when the links starts with a '#' it's a link to the Content Table-->
+ <xsl:choose>
+ <xsl:when test="starts-with($nextDocURL, '#')">
+ <xsl:call-template name="get-relative-file-ref">
+ <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
+ <xsl:with-param name="targetFileRef" select="."/>
+ </xsl:call-template>
+<!-- <xsl:value-of select="concat($contentTableURL, $nextDocURL)"/>-->
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="get-relative-file-ref">
+ <xsl:with-param name="sourceFileRef" select="$globalDocumentRefToCurrentFile"/>
+ <xsl:with-param name="targetFileRef" select="$nextDocURL"/>
+ </xsl:call-template>
+<!-- <xsl:value-of select="concat($globalDocumentDir, $nextDocURL)"/>-->
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:text>Next document</xsl:text>
+ </xsl:element>
+ </xsl:if>
+ <xsl:text> ]</xsl:text>
+ </xsl:element>
+ </xsl:element>
+ </xsl:template>
+
+
+ <xsl:template name="get-relative-file-ref">
+ <xsl:param name="sourceFileRef"/>
+ <xsl:param name="targetFileRef"/>
+
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:get-relative-file-ref')">
+ <xsl:value-of select="sxghelper:get-relative-file-ref(string($sourceFileRef), string($targetFileRef))"/>
+ </xsl:when>
+ <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getRelativeFileRef')">
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.getRelativeFileRef(string($sourceFileRef), string($targetFileRef))"/>
+ </xsl:when>
+ </xsl:choose>
+
+ </xsl:template>
+
+
+ <xsl:template name="get-name-of-table-of-content-document">
+
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:get-name-of-table-of-content-document')">
+ <xsl:value-of select="sxghelper:get-name-of-table-of-content-document()"/>
+ </xsl:when>
+ <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.getNameOfTableOfContentDocument')">
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.getNameOfTableOfContentDocument()"/>
+ </xsl:when>
+ </xsl:choose>
+
+ </xsl:template>
+
+
+ <xsl:template name="debug-content-table-headings-variable">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:message><xsl:text>**** THE HEADING VARIABLE **** </xsl:text></xsl:message>
+ <xsl:message>content-table-url: <xsl:value-of select="collectedGlobalData/content-table-headings/content-table-url"/></xsl:message>
+
+ <xsl:for-each select="$collectedGlobalData/content-table-headings/heading">
+ <xsl:message><xsl:text>**** new heading: </xsl:text></xsl:message>
+ <xsl:message>content-table-id: <xsl:value-of select="@content-table-id"/></xsl:message>
+ <xsl:message>child-document-no: <xsl:value-of select="@child-document-no"/></xsl:message>
+ <xsl:message>file-url: <xsl:value-of select="@file-url"/></xsl:message>
+ <xsl:message>out-file-url: <xsl:value-of select="@out-file-url"/></xsl:message>
+ <xsl:message>level: <xsl:value-of select="@level"/></xsl:message>
+ <xsl:message>title: <xsl:value-of select="@title"/></xsl:message>
+ <xsl:message>encoded-title: <xsl:value-of select="@encoded-title"/></xsl:message>
+ <xsl:message>absolute-chapter-level:<xsl:value-of select="@absolute-chapter-level"/></xsl:message>
+ </xsl:for-each>
+
+ </xsl:template>
+
+
+ <!-- To make the headings unique, the absolute heading is added to them
+ E.g. The level 1.2.3.4. would result into a 1+2+3+4 string -->
+ <xsl:template name="calc-chapter-numbers">
+ <xsl:param name="level"/>
+
+ <xsl:choose>
+ <xsl:when test="function-available('sxghelper:calc-chapter-numbers')">
+ <xsl:value-of select="sxghelper:calc-chapter-numbers($level)"/>
+ </xsl:when>
+ <xsl:when test="function-available('java:com.sun.star.xslt.helper.SxgChildTransformer.calcChapterNumbers')">
+ <xsl:value-of select="java:com.sun.star.xslt.helper.SxgChildTransformer.calcChapterNumbers($level)"/>
+ </xsl:when>
+ </xsl:choose>
+
+ </xsl:template>
+
+
+
+
+ <xsl:template match="text:p" mode="content-table">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:variable name="allTabStopStyles" select="$office:automatic-styles/style:style[@style:name = current()/@text:style-name]/style:properties/style:tab-stops"/>
+
+ <xsl:element name="table">
+ <xsl:attribute name="border">0</xsl:attribute>
+ <xsl:attribute name="class"><xsl:value-of select="@text:style-name"/></xsl:attribute>
+<!--
+<xsl:message>*********</xsl:message>
+<xsl:message>Stylename:<xsl:value-of select="@text:style-name"/></xsl:message>
+<xsl:message>position: <xsl:value-of select="count($allTabStopStyles/style:tab-stop)"/></xsl:message>
+-->
+
+ <xsl:element name="colgroup">
+ <xsl:call-template name="create-col-element">
+ <xsl:with-param name="lastNodePosition" select="count($allTabStopStyles/style:tab-stop)"/>
+ <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
+ </xsl:call-template>
+ </xsl:element>
+
+
+ <!-- all elements before the first tabStop -->
+ <xsl:variable name="testNo-RTF">
+ <xsl:apply-templates select="node()" mode="cell-content"/>
+ </xsl:variable>
+
+
+ <xsl:choose>
+ <xsl:when test="function-available('xt:node-set')">
+ <xsl:variable name="tabNodePositions" select="xt:node-set($testNo-RTF)"/>
+ <xsl:element name="tr">
+ <xsl:call-template name="create-td-elements">
+ <xsl:with-param name="lastNodePosition" select="count($allTabStopStyles/style:tab-stop)"/>
+ <xsl:with-param name="position" select="1"/>
+ <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
+ <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+
+ </xsl:when>
+ <xsl:when test="function-available('xalan:nodeset')">
+ <xsl:variable name="tabNodePositions" select="xalan:nodeset($testNo-RTF)"/>
+ <xsl:element name="tr">
+ <xsl:call-template name="create-td-elements">
+ <xsl:with-param name="lastNodePosition" select="count($allTabStopStyles/style:tab-stop)"/>
+ <xsl:with-param name="position" select="1"/>
+ <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
+ <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+
+ </xsl:when>
+ </xsl:choose>
+
+ <!-- <xsl:variable name="tabNodePositions" select="xt:node-set($testNo-RTF)"/>
+
+ <xsl:element name="tr">
+ <xsl:call-template name="create-td-elements">
+ <xsl:with-param name="lastNodePosition" select="count($allTabStopStyles/style:tab-stop)"/>
+ <xsl:with-param name="position" select="1"/>
+ <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
+ <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>-->
+
+
+ </xsl:element>
+ </xsl:template>
+
+
+ <xsl:template name="create-col-element">
+ <xsl:param name="lastNodePosition"/>
+ <xsl:param name="allTabStopStyles"/>
+
+ <xsl:for-each select="$allTabStopStyles/style:tab-stop">
+ <xsl:element name="col">
+ <xsl:attribute name="style">
+ <xsl:text>width: </xsl:text>
+ <xsl:call-template name="grap-cell-width">
+ <xsl:with-param name="position" select="position()"/>
+ <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:for-each>
+
+ </xsl:template>
+<!--
+Scenarios tabstops
+
+1) style:type of style:tab-stop is 'right' and earlier tabStop is not right
+ -> Earlier text-nodes and following text-nodes, will be put into an inner table, with two TD first aligned left, with proceding textnodes, the latter aligned right.
+
+2) style:type is 'right' and earlier tabStop is right
+ -> following text-nodes, will be put into a right aligned TD
+
+3) style:type is 'non-right' and earlier tabStop 'non-right' as well
+ -> put the preceding tab stops into a TD (left aligned is default)
+
+4) first style:type would have no right precedign tabStop
+ -> works well with first sceanrios 1 and 3
+
+5) last style:type would be a special case, if it would be left aligned, but this won't happen in our case.. :D
+
+Scenarios unmatched:
+- text:styleposition 'center' will not be matched in our case (effort for nothing), there will be only 'right' and not 'right'
+- If the last tabStop is not from text:stylepostion 'right', the length of the last cell is undefined and a document length must be found.
+ Not happens in our global document case. Also the algorithm below would have to be expanded (cp. scenario 5).
+
+-->
+ <xsl:template name="create-td-elements">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="lastNodePosition"/>
+ <xsl:param name="position"/>
+ <xsl:param name="allTabStopStyles"/>
+ <xsl:param name="tabNodePositions"/>
+<!--
+<xsl:message>++++++++</xsl:message>
+<xsl:message>Position: <xsl:value-of select="$position"/></xsl:message>
+<xsl:message>lastNodePosition: <xsl:value-of select="$lastNodePosition"/></xsl:message>
+-->
+
+ <xsl:variable name="currentStyleType" select="$allTabStopStyles/style:tab-stop[$position]/@style:type"/>
+ <xsl:variable name="earlierStyleType" select="$allTabStopStyles/style:tab-stop[$position - 1]/@style:type"/>
+ <xsl:choose>
+ <xsl:when test="$currentStyleType = 'right'">
+ <xsl:choose>
+ <xsl:when test="$earlierStyleType = 'right'">
+ <!--
+ 2) style:type is 'right' and earlier tabStop is right
+ -> following text-nodes, will be put into a right aligned TD -->
+ <xsl:element name="td">
+ <xsl:attribute name="style">
+ <xsl:text>align: right</xsl:text>
+ </xsl:attribute>
+ <xsl:call-template name="grap-cell-content-before-tab-stop">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="endingTabStopPosition" select="$position + 1"/>
+ <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
+ <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <!--
+ 1) style:type of style:tab-stop is 'right' and earlier tabStop is not right
+ -> Earlier text-nodes and following text-nodes, will be put into an inner table, with two TD first aligned left, with proceding textnodes, the latter aligned right.-->
+<!-- valid HTML but browsers make a line break (border=0 and paragraphstyle also missing):
+ <xsl:element name="table">
+ <xsl:element name="td">
+ <xsl:call-template name="grap-cell-content-before-tab-stop">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="endingTabStopPosition" select="$position"/>
+ <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
+ <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
+ </xsl:call-template>
+ </xsl:element>
+ <xsl:element name="td">
+ <xsl:attribute name="style">
+ <xsl:text>align: right</xsl:text>
+ </xsl:attribute>
+ <xsl:call-template name="grap-cell-content-before-tab-stop">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="endingTabStopPosition" select="$position + 1"/>
+ <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
+ <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:element>
+-->
+ <xsl:element name="td">
+ <xsl:call-template name="grap-cell-content-before-tab-stop">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="endingTabStopPosition" select="$position"/>
+ <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
+ <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
+ </xsl:call-template>
+<!-- ODK FEATURE NO PAGES
+ <xsl:element name="td">
+ <xsl:attribute name="style">
+ <xsl:text>align: right</xsl:text>
+ </xsl:attribute>
+ <xsl:call-template name="grap-cell-content-before-tab-stop">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="endingTabStopPosition" select="$position + 1"/>
+ <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
+ <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
+ </xsl:call-template>
+ </xsl:element> -->
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$earlierStyleType = 'right'">
+ </xsl:when>
+ <xsl:otherwise>
+ <!--
+ 3) style:type is 'non-right' and earlier tabStop 'non-right' as well
+ -> put the preceding tab stops into a TD (left aligned is default) -->
+ <xsl:element name="td">
+ <xsl:call-template name="grap-cell-content-before-tab-stop">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="endingTabStopPosition" select="$position"/>
+ <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
+ <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:if test="$position != $lastNodePosition">
+ <xsl:call-template name="create-td-elements">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="lastNodePosition" select="$lastNodePosition"/>
+ <xsl:with-param name="position" select="$position + 1"/>
+ <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
+ <xsl:with-param name="tabNodePositions" select="$tabNodePositions"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+
+ <xsl:template name="grap-cell-content-before-tab-stop">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="endingTabStopPosition"/>
+ <xsl:param name="tabNodePositions"/>
+ <xsl:param name="lastNodePosition"/>
+
+ <xsl:choose>
+ <xsl:when test="$endingTabStopPosition = 1">
+ <xsl:apply-templates mode="content-table" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]]">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:when test="$endingTabStopPosition > $lastNodePosition">
+ <xsl:apply-templates mode="content-table" select="node()[position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates mode="content-table" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]][position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template mode="content-table" match="text:s">
+ <xsl:call-template name="write-breakable-whitespace">
+ <xsl:with-param name="whitespaces" select="@text:c"/>
+ </xsl:call-template>
+ </xsl:template>
+
+
+ <xsl:template match="*" mode="cell-content">
+
+ <xsl:if test="name() = 'text:tab-stop' or *[name() = 'text:tab-stop']">
+ <xsl:element name="tab-stop-node-position">
+ <xsl:value-of select="position()"/>
+ </xsl:element>
+ </xsl:if>
+ </xsl:template>
+
+
+ <xsl:template name="grap-cell-width">
+ <xsl:param name="position"/>
+ <xsl:param name="allTabStopStyles"/>
+
+ <xsl:variable name="tabStopPosition" select="$allTabStopStyles/style:tab-stop[$position]/@style:position"/>
+ <xsl:choose>
+ <xsl:when test="contains($tabStopPosition, 'cm')">
+ <xsl:call-template name="create-cell-width">
+ <xsl:with-param name="width" select="number(substring-before($tabStopPosition,'cm'))"/>
+ <xsl:with-param name="unit" select="'cm'"/>
+ <xsl:with-param name="position" select="$position - 1"/>
+ <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="contains($tabStopPosition, 'in')">
+ <xsl:call-template name="create-cell-width">
+ <xsl:with-param name="width" select="number(substring-before($tabStopPosition,'in'))"/>
+ <xsl:with-param name="unit" select="'in'"/>
+ <xsl:with-param name="position" select="$position - 1"/>
+ <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="contains($tabStopPosition, 'ch')">
+ <xsl:call-template name="create-cell-width">
+ <xsl:with-param name="width" select="number(substring-before($tabStopPosition,'ch'))"/>
+ <xsl:with-param name="unit" select="'ch'"/>
+ <xsl:with-param name="position" select="$position - 1"/>
+ <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="contains($tabStopPosition, 'pt')">
+ <xsl:call-template name="create-cell-width">
+ <xsl:with-param name="width" select="number(substring-before($tabStopPosition,'pt'))"/>
+ <xsl:with-param name="unit" select="'pt'"/>
+ <xsl:with-param name="position" select="$position - 1"/>
+ <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="create-cell-width">
+ <xsl:param name="width"/>
+ <xsl:param name="unit"/>
+ <xsl:param name="position"/>
+ <xsl:param name="allTabStopStyles"/>
+
+ <xsl:choose>
+ <xsl:when test="$position > 1">
+ <xsl:call-template name="create-cell-width">
+ <xsl:with-param name="width" select="$width - number(substring-before($allTabStopStyles/style:tab-stop[$position]/@style:position,$unit))"/>
+ <xsl:with-param name="unit" select="$unit"/>
+ <xsl:with-param name="position" select="$position - 1"/>
+ <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$position = 1">
+ <xsl:value-of select="concat($width - number(substring-before($allTabStopStyles/style:tab-stop[$position]/@style:position,$unit)), $unit)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat($width, $unit)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null
+<!--
+
+ The Contents of this file are made available subject to the terms of
+ either of the following licenses
+
+ - GNU Lesser General Public License Version 2.1
+ - Sun Industry Standards Source License Version 1.1
+
+ Sun Microsystems Inc., October, 2000
+
+ GNU Lesser General Public License Version 2.1
+ =============================================
+ Copyright 2000 by Sun Microsystems, Inc.
+ 901 San Antonio Road, Palo Alto, CA 94303, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1, as published by the Free Software Foundation.
+
+ 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., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+
+ Sun Industry Standards Source License Version 1.1
+ =================================================
+ The contents of this file are subject to the Sun Industry Standards
+ Source License Version 1.1 (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.openoffice.org/license.html.
+
+ Software provided under this License is provided on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ See the License for the specific provisions governing your rights and
+ obligations concerning the Software.
+
+ The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+
+ Copyright © 2002 by Sun Microsystems, Inc.
+
+ All Rights Reserved.
+
+ Contributor(s): _______________________________________
+
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:office="http://openoffice.org/2000/office"
+ xmlns:style="http://openoffice.org/2000/style"
+ xmlns:text="http://openoffice.org/2000/text"
+ xmlns:table="http://openoffice.org/2000/table"
+ xmlns:draw="http://openoffice.org/2000/drawing"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:number="http://openoffice.org/2000/datastyle"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:chart="http://openoffice.org/2000/chart"
+ xmlns:dr3d="http://openoffice.org/2000/dr3d"
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:form="http://openoffice.org/2000/form"
+ xmlns:script="http://openoffice.org/2000/script"
+ office:class="text"
+ office:version="1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:meta="http://openoffice.org/2000/meta"
+ xmlns:config="http://openoffice.org/2001/config"
+ xmlns:help="http://openoffice.org/2000/help"
+ xmlns:xt="http://www.jclark.com/xt"
+ xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
+ xmlns:urlencoder="http://www.jclark.com/xt/java/java.net.URLEncoder"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ exclude-result-prefixes="java">
+
+ <xsl:output method ="xml"
+ encoding ="UTF-8"
+ indent ="yes"/>
+
+
+
+ <!--+++++ INCLUDED XSL MODULES +++++-->
+ <!-- inherited style properties will be collected and written in a CSS header (CSS) -->
+ <xsl:include href="style_header.xsl"/>
+
+ <!-- inherited style properties will be collected and written as html properties in a temporary variable (HTML4, PALM) -->
+ <xsl:include href="style_inlined.xsl"/>
+
+ <!-- our xml style properties will be mapped to CSS and HTML4.x properties -->
+ <xsl:include href="style_mapping.xsl"/>
+
+ <!-- common element handling -->
+ <xsl:include href="common.xsl"/>
+
+ <!-- table handling -->
+ <xsl:include href="table.xsl"/>
+
+ <!-- palm handling -->
+ <xsl:include href="palm.xsl"/>
+
+ <!-- global document handling -->
+ <xsl:include href="global_document.xsl"/>
+
+
+
+
+
+
+
+ <!--+++++ PARAMETER FROM THE APPLICATION AND GLOBAL VARIABLES +++++-->
+
+ <!-- MANDATORY: URL of meta stream -->
+ <xsl:param name="metaFileURL"/>
+
+ <!-- MANDATORY: URL of styles stream -->
+ <xsl:param name="stylesFileURL"/>
+
+ <!-- MANDATORY: for resolving relative links
+ For resolving realtive links to the packed SO document, i.e. the path/URL of the jared sxw file (e.g. meta.xml, styles.xml, links to graphics in a relative directory) -->
+ <xsl:param name="absoluteSourceDirRef"/>
+
+ <!-- OPTIONAL (mandatory, when when source is compressed): Necessary for the in the packed OO document embedded files (mostly graphics from the compressed /Picture dir).
+ When the OpenOffice (OO) file has been unpacked the absoluteSoureDirRef can be taken,
+ Otherwise, a JAR URL could be choosen or when working with OpenOffice a so called Package-URL encoded over HTTP can be used to
+ access the jared contents of the the jared document. . -->
+ <xsl:param name="jaredRootURL" select="$absoluteSourceDirRef"/>
+
+ <!-- OPTIONAL (mandatory, when used in session based environment)
+ Useful for WebApplications: if a HTTP session is not cookie based, URL rewriting is beeing used (the session is appended to the URL).
+ This URL session is used when creating links to graphics by XSLT. Otherwise the user havt to log again in for every graphic he would like to see. -->
+ <xsl:param name="optionalURLSuffix"/>
+
+ <!-- OPTIONAL: DPI (dots per inch) the standard solution of given pictures (necessary for the conversion of 'cm' into 'pixel')-->
+ <!-- Although many pictures have the 96 dpi resolution, a higher resoltion give better results for common browsers -->
+ <xsl:param name="dpi" select="96"/>
+
+ <!-- OPTIONAL: in case of using a different processor than a JAVA XSLT, you can unable the Java functionality
+ (i.e. debugging time and encoding chapter names for the content-table as href and anchors ) -->
+ <xsl:param name="disableJava" select="false"/>
+ <xsl:param name="isJavaDisabled" select="boolean($disableJava)"/>
+
+ <!-- OPTIONAL: user-agent will be differntiated by this parameter given by application (e.g. java servlet)-->
+ <xsl:param name="outputType" select="'CSS_HEADER'"/>
+ <!-- set of possible deviceTyps (WML is set in its own startfile main_wml.xsl):
+ <xsl:param name="outputType" select="'CSS_HEADER'"/>
+ <xsl:param name="outputType" select="'CSS_INLINED'"/>
+ <xsl:param name="outputType" select="'PALM'"/> -->
+
+ <!-- OPTIONAL: for activating the debug mode set the variable here to 'true()' or give any value from outside -->
+ <xsl:param name="debug" select="false"/>
+ <xsl:param name="isDebugMode" select="boolean($debug)"/>
+
+<!-- *************************************************************************
+ OPTIONAL: NEEDED IN CONNECTION WITH A GLOBAL DOCUMENT -->
+
+ <!--SUMMARY:
+ following parameter triggers a (quite time consuming) enabling of bookmarks in the table-of-content.
+ IN DETAIL:
+ Currently some links used in the Office XML (e.g. in the content table as '#7.Some%20Example%20Headline%7Outline')
+ is not a valid URL (cmp. bug id# 102311). No file destination is specified nor exist any anchor element for these
+ links in the Office XML.
+ A workaround for this transformation therefore had to be made. This time-consuming mechanism is disabled by default and
+ can be activated by a parameter (i.e. 'disableLinkedTableOfContent'). A creation of an anchor is made for each header element.
+ All header titles gonna be encoding to be usable in a relative URL. -->
+ <xsl:param name="disableLinkedTableOfContent" select="false()"/>
+
+ <!-- The chapter numbers of the current document (as a sequence of a global document) is dependent of the number
+ of chapter of the same level in preceding documents. -->
+ <xsl:param name="precedingChapterLevel1" select="0"/>
+ <xsl:param name="precedingChapterLevel2" select="0"/>
+ <xsl:param name="precedingChapterLevel3" select="0"/>
+ <xsl:param name="precedingChapterLevel4" select="0"/>
+ <xsl:param name="precedingChapterLevel5" select="0"/>
+ <xsl:param name="precedingChapterLevel6" select="0"/>
+ <xsl:param name="precedingChapterLevel7" select="0"/>
+ <xsl:param name="precedingChapterLevel8" select="0"/>
+ <xsl:param name="precedingChapterLevel9" select="0"/>
+ <xsl:param name="precedingChapterLevel10" select="0"/>
+
+ <!-- XML documents containing a table of contents,
+ gonna link for usability reason above each chapter to the preceding and following document and the content table -->
+ <xsl:param name="contentTableURL"/>
+
+ <!-- Needed for the bug workaround of missing content table links
+ by this ambigous HTML references from the content table can be evoided-->
+ <xsl:param name="globalDocumentRefToCurrentFile"/>
+
+ <!-- Needed for the bug workaround of missing content table links
+ by this node-set the relation between content-table link and children document header can be unambigous established -->
+ <xsl:param name="contentTableHeadings"/>
+
+
+<!-- END OF GLOBAL DOCUMENT SECTION
+*************************************************************************-->
+
+
+
+ <!-- works for normal separated zipped xml files as for flat filter single xml file format as well -->
+ <xsl:variable name="office:meta-file" select="document($metaFileURL)"/>
+ <xsl:variable name="office:styles-file" select="document($stylesFileURL)"/>
+ <xsl:variable name="office:font-decls" select="$office:styles-file/*/office:font-decls"/>
+ <xsl:variable name="office:styles" select="$office:styles-file/*/office:styles"/>
+ <!-- office:automatic-styles may occure in two different files (i.d. content.xml and styles.xml). Furthermore the top level tag is different in a flat xml file -->
+ <xsl:variable name="office:automatic-styles" select="/*/office:automatic-styles"/>
+
+ <!-- simple declaration of WML used to avoid parser errors -->
+ <xsl:variable name="wap-paragraph-elements-without-table-row"/>
+ <xsl:variable name="wap-paragraph-elements"/>
+ <xsl:template name="wml-repeat-write-row"/>
+
+
+ <!-- ************************************* -->
+ <!-- *** build the propriate HTML file *** -->
+ <!-- ************************************* -->
+
+ <xsl:template match="/">
+
+ <!--<xsl:message>
+
+
+ Entered the styleSheets, transformation begins... </xsl:message>-->
+
+ <xsl:choose>
+ <xsl:when test="$isDebugMode">
+ <xsl:call-template name="check-parameter"/>
+
+ <xsl:if test="not($isJavaDisabled)">
+ <xsl:call-template name="debug-style-collecting-time"/>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- to access the variable like a node-set it is necessary to convert it
+ from a result-tree-fragment (RTF) to a node set using the James Clark extension -->
+ <xsl:variable name="collectedGlobalData-RTF">
+ <xsl:call-template name='create-all-inline-styles'/>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="function-available('xt:node-set')">
+ <xsl:call-template name="start">
+ <xsl:with-param name="collectedGlobalData" select="xt:node-set($collectedGlobalData-RTF)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="function-available('xalan:nodeset')">
+ <xsl:call-template name="start">
+ <xsl:with-param name="collectedGlobalData" select="xalan:nodeset($collectedGlobalData-RTF)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="NodeSetFunctionNotAvailable"/>
+ <xsl:call-template name="start"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="start">
+ <xsl:param name="collectedGlobalData"/>
+
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER'">
+ <xsl:element name="html">
+ <xsl:element name="head">
+ <xsl:if test="$isDebugMode"><xsl:message>CSS helper variable will be created....</xsl:message></xsl:if>
+ <xsl:call-template name='common-header-properties'/>
+ <xsl:if test="$isDebugMode"><xsl:message>CSS variable ready, header will be created....</xsl:message></xsl:if>
+ <!-- constructing the css header simulating inheritance of style-families by style order -->
+ <xsl:call-template name='create-css-styleheader'/>
+ <xsl:if test="$isDebugMode"><xsl:message>CSS header creation finished!</xsl:message></xsl:if>
+ </xsl:element>
+
+
+
+ <xsl:variable name="backgroundImageURL" select="$office:automatic-styles/style:page-master/style:properties/style:background-image/@xlink:href"/>
+ <xsl:element name="body">
+ <!-- background image -->
+ <xsl:if test="$backgroundImageURL">
+ <xsl:attribute name="background">
+ <xsl:choose>
+ <!-- for images jared in open office document -->
+ <xsl:when test="contains($backgroundImageURL, '#Pictures/')">
+ <!-- creating an absolute http URL to the contained/packed image file -->
+ <xsl:value-of select="concat($jaredRootURL, '/Pictures/', substring-after($backgroundImageURL, '#Pictures/'), $optionalURLSuffix)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="src"><xsl:value-of select="$backgroundImageURL"/></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+
+ <!-- processing the content of the xml file -->
+ <xsl:apply-templates select="/*/office:body">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:element>
+
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ HTML 4.0 INLINING +++++-->
+ <xsl:when test="$outputType = 'CSS_INLINED'">
+ <xsl:element name="html">
+ <xsl:element name="head">
+ <xsl:call-template name='common-header-properties'/>
+ </xsl:element>
+
+ <xsl:variable name="backgroundImageURL" select="$office:automatic-styles/style:page-master/style:properties/style:background-image/@xlink:href"/>
+ <xsl:element name="body">
+ <!-- background image -->
+ <xsl:if test="$backgroundImageURL">
+ <xsl:attribute name="background">
+ <xsl:choose>
+ <!-- for images jared in open office document -->
+ <xsl:when test="contains($backgroundImageURL, '#Pictures/')">
+ <!-- creating an absolute http URL to the contained/packed image file -->
+ <xsl:value-of select="concat($jaredRootURL, '/Pictures/', substring-after($backgroundImageURL, '#Pictures/'), $optionalURLSuffix)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="src"><xsl:value-of select="$backgroundImageURL"/></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select="/*/office:body">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:element>
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ PALM-VII (3.2 HTML SUBSET) +++++-->
+ <xsl:when test="$outputType = 'PALM'">
+ <!-- the proxy will convert the html file later to PQA -->
+ <xsl:element name="html">
+ <xsl:element name="head">
+ <xsl:call-template name='palm-header-properties'/>
+ </xsl:element>
+
+ <xsl:element name="body">
+ <!-- processing the content of the xml file -->
+ <xsl:apply-templates select="/*/office:body">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:element>
+ </xsl:element>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <!-- ********************************************* -->
+ <!-- *** Header for CSS_INLINED and CSS_HEADER *** -->
+ <!-- ********************************************* -->
+
+ <xsl:template name='common-header-properties'>
+ <xsl:apply-templates select="$office:meta-file/*/office:meta/dc:title"/>
+ <xsl:apply-templates select="$office:meta-file/*/office:meta/dc:description"/>
+<!--2DO add further header elements..
+ <xsl:apply-templates select="$office:meta-file/*/office:meta/dc:subject"/>
+ <xsl:apply-templates select="$office:meta-file/*/office:meta/meta:keywords[postition()=1]"/>-->
+ </xsl:template>
+
+ <xsl:template match="dc:title">
+ <xsl:element name="title">
+ <xsl:value-of select="."/>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="dc:description">
+ <xsl:element name="meta">
+ <xsl:attribute name="name">
+ <xsl:text>description</xsl:text>
+ </xsl:attribute>
+ <xsl:attribute name="content">
+ <xsl:value-of select="."/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:template>
+
+
+ <!-- ********************************************* -->
+ <!-- *** Measuring the time for style creating *** -->
+ <!-- ********************************************* -->
+
+
+ <xsl:template name="debug-style-collecting-time">
+
+ <xsl:variable name="startTime-RTF">
+ <xsl:choose>
+ <xsl:when test="function-available('system:current-time-millis')">
+ <xsl:value-of select="system:current-time-millis()"/>
+ </xsl:when>
+ <xsl:when test="function-available('java:java.lang.System.currentTimeMillis')">
+ <xsl:value-of select="java:java.lang.System.currentTimeMillis()"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+
+
+
+ <xsl:variable name="collectedGlobalData-RTF">
+ <xsl:call-template name='create-all-inline-styles'/>
+ </xsl:variable>
+
+
+ <xsl:choose>
+ <xsl:when test="function-available('xt:node-set')">
+ <xsl:message>Creating the inline styles....</xsl:message>
+ <xsl:variable name="startTime" select="number(xt:node-set($startTime-RTF))"/>
+ <xsl:variable name="collectedGlobalData" select="xt:node-set($collectedGlobalData-RTF)"/>
+ <xsl:variable name="endTime" select="system:current-time-millis()"/>
+
+ <xsl:message>Time for instantiating style variable: <xsl:value-of select="($endTime - $startTime)"/> ms</xsl:message>
+ <xsl:call-template name="start">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="function-available('xalan:nodeset')">
+ <xsl:message>Creating the inline styles....</xsl:message>
+ <xsl:variable name="startTime" select="number(xalan:nodeset($startTime-RTF))"/>
+ <xsl:variable name="endTime" select="java:java.lang.System.currentTimeMillis()"/>
+ <xsl:variable name="collectedGlobalData" select="xalan:nodeset($collectedGlobalData-RTF)"/>
+
+ <xsl:message>Time for instantiating style variable: <xsl:value-of select="($endTime - $startTime)"/> ms</xsl:message>
+ <xsl:call-template name="start">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <!-- DEBUG purpose only: checking the parameters of this template-->
+ <xsl:template name="check-parameter">
+ <xsl:message>Parameter dpi: <xsl:value-of select="$dpi"/></xsl:message>
+ <xsl:message>Parameter metaFileURL: <xsl:value-of select="$metaFileURL"/></xsl:message>
+ <xsl:message>Parameter stylesFileURL: <xsl:value-of select="$stylesFileURL"/></xsl:message>
+ <xsl:message>Parameter absoluteSourceDirRef: <xsl:value-of select="$absoluteSourceDirRef"/></xsl:message>
+ <xsl:message>Parameter precedingChapterLevel1 : <xsl:value-of select="$precedingChapterLevel1"/></xsl:message>
+ <xsl:message>Parameter precedingChapterLevel2 : <xsl:value-of select="$precedingChapterLevel2"/></xsl:message>
+ <xsl:message>Parameter precedingChapterLevel3 : <xsl:value-of select="$precedingChapterLevel3"/></xsl:message>
+ <xsl:message>Parameter precedingChapterLevel4 : <xsl:value-of select="$precedingChapterLevel4"/></xsl:message>
+ <xsl:message>Parameter precedingChapterLevel5 : <xsl:value-of select="$precedingChapterLevel5"/></xsl:message>
+ <xsl:message>Parameter precedingChapterLevel6 : <xsl:value-of select="$precedingChapterLevel6"/></xsl:message>
+ <xsl:message>Parameter precedingChapterLevel7 : <xsl:value-of select="$precedingChapterLevel7"/></xsl:message>
+ <xsl:message>Parameter precedingChapterLevel8 : <xsl:value-of select="$precedingChapterLevel8"/></xsl:message>
+ <xsl:message>Parameter precedingChapterLevel9 : <xsl:value-of select="$precedingChapterLevel9"/></xsl:message>
+ <xsl:message>Parameter precedingChapterLevel10: <xsl:value-of select="$precedingChapterLevel10"/></xsl:message>
+ </xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<!--
+
+ The Contents of this file are made available subject to the terms of
+ either of the following licenses
+
+ - GNU Lesser General Public License Version 2.1
+ - Sun Industry Standards Source License Version 1.1
+
+ Sun Microsystems Inc., October, 2000
+
+ GNU Lesser General Public License Version 2.1
+ =============================================
+ Copyright 2000 by Sun Microsystems, Inc.
+ 901 San Antonio Road, Palo Alto, CA 94303, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1, as published by the Free Software Foundation.
+
+ 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., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+
+ Sun Industry Standards Source License Version 1.1
+ =================================================
+ The contents of this file are subject to the Sun Industry Standards
+ Source License Version 1.1 (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.openoffice.org/license.html.
+
+ Software provided under this License is provided on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ See the License for the specific provisions governing your rights and
+ obligations concerning the Software.
+
+ The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+
+ Copyright © 2002 by Sun Microsystems, Inc.
+
+ All Rights Reserved.
+
+ Contributor(s): _______________________________________
+
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:office="http://openoffice.org/2000/office"
+ xmlns:style="http://openoffice.org/2000/style"
+ xmlns:text="http://openoffice.org/2000/text"
+ xmlns:table="http://openoffice.org/2000/table"
+ xmlns:draw="http://openoffice.org/2000/drawing"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:number="http://openoffice.org/2000/datastyle"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:chart="http://openoffice.org/2000/chart"
+ xmlns:dr3d="http://openoffice.org/2000/dr3d"
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:form="http://openoffice.org/2000/form"
+ xmlns:script="http://openoffice.org/2000/script"
+ office:class="text"
+ office:version="1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:meta="http://openoffice.org/2000/meta"
+ xmlns:config="http://openoffice.org/2001/config"
+ xmlns:help="http://openoffice.org/2000/help"
+ xmlns:xt="http://www.jclark.com/xt"
+ xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ exclude-result-prefixes="java">
+
+ <xsl:output cdata-section-elements="meta"/>
+
+
+ <!-- **************************** -->
+ <!-- *** specific palm header *** -->
+ <!-- **************************** -->
+
+ <xsl:template name='palm-header-properties'>
+ <xsl:element name="meta">
+ <xsl:attribute name="name">PalmComputingPlatform</xsl:attribute>
+ <xsl:attribute name="content">true</xsl:attribute>
+ </xsl:element>
+ <xsl:element name="meta">
+ <xsl:attribute name="name">HandheldFriendly</xsl:attribute>
+ <xsl:attribute name="content">true</xsl:attribute>
+ </xsl:element>
+ <xsl:element name="meta">
+ <xsl:attribute name="name">HistoryListText</xsl:attribute>
+ <xsl:attribute name="content">Dateimanager : &date &time</xsl:attribute>
+ </xsl:element>
+ <xsl:element name="meta">
+ <xsl:attribute name="name">description</xsl:attribute>
+ <xsl:attribute name="content">StarPortal</xsl:attribute>
+ </xsl:element>
+ <xsl:element name="meta">
+ <xsl:attribute name="name">keywords</xsl:attribute>
+ <xsl:attribute name="content">starportal, staroffice, software</xsl:attribute>
+ </xsl:element>
+ <xsl:element name="meta">
+ <xsl:attribute name="http-equiv">Content-Type</xsl:attribute>
+ <xsl:attribute name="content">text/html; charset=iso-8859-1</xsl:attribute>
+ </xsl:element>
+ </xsl:template>
+
+
+ <!-- ********************************* -->
+ <!-- *** creating table attributes *** -->
+ <!-- ********************************* -->
+
+ <!-- table data (td) and table header (th) attributes -->
+ <xsl:template name="create-attribute-ALIGN">
+ <xsl:param name="styleProperties"/>
+
+ <xsl:if test="contains($styleProperties, 'align')">
+ <xsl:attribute name="align">
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'align:left')">
+ <xsl:text>left</xsl:text>
+ </xsl:when>
+ <xsl:when test="contains($styleProperties, 'align:right')">
+ <xsl:text>right</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>center</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:if>
+ </xsl:template>
+
+
+ <!-- ********************************* -->
+ <!-- *** creating List attributes *** -->
+ <!-- ********************************* -->
+<!--
+ <xsl:template name="create-list-attributes">
+ <xsl:param name="styleProperties"/>
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+2 be implemented
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+ </xsl:template>
+-->
+
+ <!-- ************************************************ -->
+ <!-- *** creating nested format tags (PALM & WML) *** -->
+ <!-- ************************************************ -->
+
+ <!-- Italic -->
+ <xsl:template name="create-nested-format-tags">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="styleProperties"/>
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'italic')">
+ <xsl:element name="i">
+ <xsl:call-template name="bold">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="bold">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- Bold -->
+ <xsl:template name="bold">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="styleProperties"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'bold')">
+ <xsl:element name="b">
+ <xsl:call-template name="underline">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="underline">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- Underline : last format attribute, which is also used from WML - WML ends here! -->
+ <xsl:template name="underline">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="styleProperties"/>
+
+ <xsl:choose>
+ <xsl:when test="$outputType = 'PALM'">
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'underline')">
+ <xsl:element name="u">
+ <xsl:call-template name="strikethrough">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="strikethrough">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'underline')">
+ <xsl:element name="u">
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- strikethrough -->
+ <xsl:template name="strikethrough">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="styleProperties"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'strike')">
+ <xsl:element name="strike">
+ <xsl:call-template name="align">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="align">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- Alignment -->
+ <xsl:template name="align">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="styleProperties"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'align')">
+ <xsl:element name="div">
+ <xsl:attribute name="align">
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'align:left')">
+ <xsl:text>left</xsl:text>
+ </xsl:when>
+ <xsl:when test="contains($styleProperties, 'align:right')">
+ <xsl:text>right</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>center</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:call-template name="font_combined">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="font_combined">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- Both size and Color for font -->
+ <xsl:template name="font_combined">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="styleProperties"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'color') and contains($styleProperties, 'size')">
+ <xsl:element name="font">
+
+ <xsl:attribute name="color">
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'color:#000000')">
+ <xsl:text>#000000</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>#FFFFFF</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <xsl:attribute name="size">
+ <xsl:value-of select="substring-after(substring-before($styleProperties ,':size'), 'size:')"/>
+ </xsl:attribute>
+
+ <!-- get the embedded content -->
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="font_simple">
+ <xsl:with-param name="styleProperties" select="$styleProperties"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- size or Color for font -->
+ <xsl:template name="font_simple">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="styleProperties"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'color')">
+ <xsl:element name="font">
+ <xsl:attribute name="color">
+ <xsl:choose>
+ <xsl:when test="contains($styleProperties, 'color:#000000')">
+ <xsl:text>#000000</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>#FFFFFF</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <!-- get the embedded content -->
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:element>
+ </xsl:when>
+
+ <xsl:when test="contains($styleProperties, 'size')">
+ <xsl:element name="font">
+ <xsl:attribute name="size">
+ <xsl:value-of select="substring-after(substring-before($styleProperties ,':size'), 'size:')"/>
+ </xsl:attribute>
+
+ <!-- get the embedded content -->
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:element>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <!-- get the embedded content -->
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+</xsl:stylesheet>
--- /dev/null
+<!--
+
+ The Contents of this file are made available subject to the terms of
+ either of the following licenses
+
+ - GNU Lesser General Public License Version 2.1
+ - Sun Industry Standards Source License Version 1.1
+
+ Sun Microsystems Inc., October, 2000
+
+ GNU Lesser General Public License Version 2.1
+ =============================================
+ Copyright 2000 by Sun Microsystems, Inc.
+ 901 San Antonio Road, Palo Alto, CA 94303, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1, as published by the Free Software Foundation.
+
+ 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., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+
+ Sun Industry Standards Source License Version 1.1
+ =================================================
+ The contents of this file are subject to the Sun Industry Standards
+ Source License Version 1.1 (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.openoffice.org/license.html.
+
+ Software provided under this License is provided on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ See the License for the specific provisions governing your rights and
+ obligations concerning the Software.
+
+ The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+
+ Copyright © 2002 by Sun Microsystems, Inc.
+
+ All Rights Reserved.
+
+ Contributor(s): _______________________________________
+
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:office="http://openoffice.org/2000/office"
+ xmlns:style="http://openoffice.org/2000/style"
+ xmlns:text="http://openoffice.org/2000/text"
+ xmlns:table="http://openoffice.org/2000/table"
+ xmlns:draw="http://openoffice.org/2000/drawing"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:number="http://openoffice.org/2000/datastyle"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:chart="http://openoffice.org/2000/chart"
+ xmlns:dr3d="http://openoffice.org/2000/dr3d"
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:form="http://openoffice.org/2000/form"
+ xmlns:script="http://openoffice.org/2000/script"
+ office:class="text"
+ office:version="1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:meta="http://openoffice.org/2000/meta"
+ xmlns:config="http://openoffice.org/2001/config"
+ xmlns:help="http://openoffice.org/2000/help"
+ xmlns:xt="http://www.jclark.com/xt"
+ xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ exclude-result-prefixes="java">
+
+
+
+ <!-- ****************************** -->
+ <!-- *** style sheet processing *** -->
+ <!-- ****************************** -->
+
+
+ <xsl:template name='create-css-styleheader'>
+ <xsl:comment>
+ <xsl:text>The CSS style header method for setting styles</xsl:text>
+ </xsl:comment>
+ <xsl:element name="style">
+ <xsl:attribute name="type">text/css</xsl:attribute>
+ <xsl:comment>
+ <xsl:text>
+
+ </xsl:text>
+ <xsl:call-template name="write-default-styles"/>
+
+ <!-- THE STYLE PROPERTIES OF THE FIRST WRITTEN STYLE (PARENT) IS GIVEN OUT -->
+
+ <!-- 1) styles from office:styles are possible parent from all (itself or office:automatic-styles).
+ Therefore they are created first.
+ Beginning with the top-level parents (the styles without any parent). -->
+ <xsl:for-each select="$office:styles/style:style[not(@style:parent-style-name)]">
+
+ <xsl:call-template name="write-styleproperty-line"/>
+ <xsl:call-template name="write-styleproperty-lines-for-children"/>
+ </xsl:for-each>
+
+ <xsl:text> </xsl:text>
+
+ <!-- 2) styles from office:automatic-styles can only be parent of styles from the office:automatic-styles section.
+ Beginning with top-level styles, again, all children style will be recursivly traversed -->
+ <xsl:for-each select="$office:automatic-styles/style:style[not(@style:parent-style-name)]">
+ <xsl:call-template name="write-styleproperty-line">
+ <xsl:with-param name="searchOnlyInAutomaticStyles" select="true()"/>
+ </xsl:call-template>
+ <xsl:call-template name="write-styleproperty-lines-for-children">
+ <xsl:with-param name="searchOnlyInAutomaticStyles"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ //</xsl:comment>
+ </xsl:element>
+ </xsl:template>
+
+
+ <xsl:template name='write-styleproperty-line'>
+ <xsl:param name="searchOnlyInAutomaticStyles"/>
+
+ <xsl:variable name="styleProperties">
+ <xsl:call-template name="write-style-properties">
+ <xsl:with-param name="styleAttributePath" select="current()/style:properties/@*"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <!-- do not write styles with no css property -->
+ <xsl:if test="not(string-length($styleProperties) = 0)">
+ <!-- write out the name of the current (parent) style in the CSS headersection (e.g. "span.myStyle") -->
+ <xsl:call-template name="write-style-name">
+ <xsl:with-param name="is-parent-style" select="true()"/>
+ </xsl:call-template>
+
+ <!-- the names of all styles children will be written out(office:style AND office:automatic-style) -->
+ <xsl:call-template name="write-children-style-names">
+ <xsl:with-param name="parentStyleName" select="@style:name"/>
+ <xsl:with-param name="parentStyleFamily" select="@style:family"/>
+ <xsl:with-param name="searchOnlyInAutomaticStyles"/>
+ </xsl:call-template>
+
+ <!-- the style properties of the first written style (parent) is given out -->
+ <xsl:text> {
+ </xsl:text>
+ <xsl:value-of select="$styleProperties"/>
+ <xsl:text>}
+ </xsl:text>
+
+ </xsl:if>
+
+
+
+ </xsl:template>
+
+
+
+
+ <!-- RECURSION WITH ENDCONDITON: adding style classes for all existing childs -->
+ <xsl:template name='write-styleproperty-lines-for-children'>
+ <xsl:param name="searchOnlyInAutomaticStyles"/>
+
+ <xsl:variable name="parentStyleName" select="@style:name"/>
+ <xsl:variable name="parentStyleFamily" select="@style:family"/>
+
+ <xsl:if test="not(searchOnlyInAutomaticStyles)">
+ <xsl:for-each select="../style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
+ <xsl:call-template name="write-styleproperty-line"/>
+ <xsl:call-template name="write-styleproperty-lines-for-children"/>
+ </xsl:for-each>
+ </xsl:if>
+ <xsl:for-each select="$office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
+ <xsl:call-template name="write-styleproperty-line">
+ <xsl:with-param name="searchOnlyInAutomaticStyles"/>
+ </xsl:call-template>
+ <xsl:call-template name="write-styleproperty-lines-for-children">
+ <xsl:with-param name="searchOnlyInAutomaticStyles"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:template>
+
+
+ <xsl:template name="write-default-styles">
+
+ <!-- some default attributes in xml have to be explicitly set in HTML (e.g. margin-top="0") -->
+ <xsl:text>*.OOo_defaults</xsl:text>
+
+ <xsl:for-each select="$office:styles/style:style">
+ <xsl:text>, </xsl:text>
+ <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
+ </xsl:for-each>
+
+ <xsl:for-each select="$office:automatic-styles/style:style">
+ <xsl:text>, </xsl:text>
+ <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
+ </xsl:for-each>
+ <!-- 2DO: the defaults might be better collected and written in a separated (XML) file -->
+<xsl:text> {
+ margin-top:0cm; margin-bottom:0cm; }
+ </xsl:text>
+
+ <xsl:for-each select="$office:styles/style:default-style">
+ <xsl:call-template name="write-default-style"/>
+ </xsl:for-each>
+
+ <xsl:for-each select="$office:automatic-styles/style:default-style">
+ <xsl:call-template name="write-default-style"/>
+ </xsl:for-each>
+
+ </xsl:template>
+
+
+
+ <xsl:template name="write-default-style">
+ <xsl:variable name="family-style" select="@style:family"/>
+
+ <!-- some default attributes for format families (e.g. graphics, paragraphs, etc.) written as style:default-style -->
+ <xsl:value-of select="concat('*.', translate($family-style, '. %()/\', ''), '_defaults')"/>
+
+ <xsl:for-each select="$office:styles/style:style[@style:family = $family-style]">
+ <xsl:text>, </xsl:text>
+ <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
+ </xsl:for-each>
+
+ <xsl:for-each select="$office:automatic-styles/style:style[@style:family = $family-style]">
+ <xsl:text>, </xsl:text>
+ <xsl:value-of select="concat('*.', translate(@style:name, '. %()/\', ''))"/>
+ </xsl:for-each>
+
+
+ <xsl:variable name="styleProperties">
+ <xsl:call-template name="write-style-properties">
+ <xsl:with-param name="styleAttributePath" select="current()/style:properties/@*"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <!-- do not write styles with no css property -->
+ <xsl:if test="not(string-length($styleProperties) = 0)">
+ <!-- the style properties of the first written style (parent) is given out -->
+ <xsl:text> {
+ </xsl:text>
+ <xsl:value-of select="$styleProperties"/>
+ <xsl:text>}
+ </xsl:text>
+ </xsl:if>
+
+ </xsl:template>
+
+
+ <!--++
+ The parent style will be written out!
+ For each Style:family a prefix must be added
+ <!ENTITY % styleFamily
+ "(paragraph|text|section|table|table-column|table-row|table-cell|table-page|chart|graphics|default|drawing-page|presentation|control)">
+ ++-->
+ <xsl:template name="write-style-name">
+ <xsl:param name="is-parent-style"/>
+
+ <!-- This construct is for list elements. Whenever a paragraph element is being used as child of a list element the name paragraph style is been used for
+ the list item. This can be switched as the paragaph style-name and the list-style-name are in the same element.
+ Otherwise there would be formatting errors (e.g. margin-left will be used for the content in the list elment and not for the list element itself). -->
+ <xsl:variable name="style-name">
+ <xsl:choose>
+ <xsl:when test="@style:list-style-name">
+ <xsl:value-of select="@style:list-style-name"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@style:name"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:if test="not($is-parent-style)">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+
+ <xsl:choose>
+ <!-- normally 'p.' would be used as CSS element,
+ but header (h1, h2,...) are also from the style:family paragraph -->
+ <xsl:when test="@style:family='paragraph'">
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='text'">
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='section'">
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='table'">
+ <xsl:value-of select="concat('table.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='table-column'">
+ <!-- as column styles have to be included as span styles AFTER the table (no two class attributes in TD allowed -->
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='table-row'">
+ <xsl:value-of select="concat('tr.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='table-cell'">
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='table-page'">
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='chart'">
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='graphics'">
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='default'">
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='drawing-page'">
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='presentation'">
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ <xsl:when test="@style:family='control'">
+ <xsl:value-of select="concat('*.', translate($style-name, '. %()/\', ''))"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- finding all style child of a section and give their styleIdentifier to the output -->
+ <xsl:template name='write-children-style-names'>
+ <xsl:param name="parentStyleName" select="@style:name"/>
+ <xsl:param name="parentStyleFamily" select="@style:family"/>
+ <xsl:param name="searchOnlyInAutomaticStyles"/>
+
+
+ <!--** the names of all office:styles children will be written out
+ ** (a automatic style can only have children in the office:automatic-style section) -->
+
+ <!-- if NOT called from a office:automatic-style parent -->
+ <xsl:if test="not(searchOnlyInAutomaticStyles)">
+ <!-- for all children in the office:style section -->
+ <xsl:for-each select="../style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
+ <!-- write the style name in the css header -->
+ <xsl:call-template name="write-style-name"/>
+
+ <!-- search for child styles -->
+ <xsl:call-template name="write-children-style-names">
+ <xsl:with-param name="parentStyleName" select="@style:name"/>
+ <xsl:with-param name="parentStyleFamily" select="@style:family"/>
+ </xsl:call-template>
+
+ </xsl:for-each>
+ </xsl:if>
+
+ <!--** the names of all office:automatic-styles children will be written out -->
+
+ <!-- for all children in the office:automatic-style section -->
+ <xsl:for-each select="$office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
+ <!-- write the style name in the css header -->
+ <xsl:call-template name="write-style-name"/>
+
+ <!-- search for child styles -->
+ <xsl:call-template name="write-children-style-names">
+ <xsl:with-param name="parentStyleName" select="@style:name"/>
+ <xsl:with-param name="parentStyleFamily" select="@style:family"/>
+ <xsl:with-param name="searchOnlyInAutomaticStyles"/>
+ </xsl:call-template>
+
+ </xsl:for-each>
+ </xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<!--
+
+ The Contents of this file are made available subject to the terms of
+ either of the following licenses
+
+ - GNU Lesser General Public License Version 2.1
+ - Sun Industry Standards Source License Version 1.1
+
+ Sun Microsystems Inc., October, 2000
+
+ GNU Lesser General Public License Version 2.1
+ =============================================
+ Copyright 2000 by Sun Microsystems, Inc.
+ 901 San Antonio Road, Palo Alto, CA 94303, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1, as published by the Free Software Foundation.
+
+ 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., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+
+ Sun Industry Standards Source License Version 1.1
+ =================================================
+ The contents of this file are subject to the Sun Industry Standards
+ Source License Version 1.1 (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.openoffice.org/license.html.
+
+ Software provided under this License is provided on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ See the License for the specific provisions governing your rights and
+ obligations concerning the Software.
+
+ The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+
+ Copyright © 2002 by Sun Microsystems, Inc.
+
+ All Rights Reserved.
+
+ Contributor(s): _______________________________________
+
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:office="http://openoffice.org/2000/office"
+ xmlns:style="http://openoffice.org/2000/style"
+ xmlns:text="http://openoffice.org/2000/text"
+ xmlns:table="http://openoffice.org/2000/table"
+ xmlns:draw="http://openoffice.org/2000/drawing"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:number="http://openoffice.org/2000/datastyle"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:chart="http://openoffice.org/2000/chart"
+ xmlns:dr3d="http://openoffice.org/2000/dr3d"
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:form="http://openoffice.org/2000/form"
+ xmlns:script="http://openoffice.org/2000/script"
+ office:class="text"
+ office:version="1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:meta="http://openoffice.org/2000/meta"
+ xmlns:config="http://openoffice.org/2001/config"
+ xmlns:help="http://openoffice.org/2000/help"
+ xmlns:xt="http://www.jclark.com/xt"
+ xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ exclude-result-prefixes="java">
+
+
+
+ <!-- ********************************************* -->
+ <!-- *** hard attributed (inlined) properties *** -->
+ <!-- ********************************************* -->
+
+
+ <!-- RESTRICTIONS:
+ 1) As the styles-node-variables are NOT global, the style variables are not global, either!!
+ 2) As a list of elements can only be added to a variable as a result tree fragment the
+ extension is neccessary!!
+ -->
+
+ <!-- 2DO: Inline styles do not inherit from XML office defaults nor font:family defaults as the style header does
+ (cp. stylesheet 'style_header.xsl' and the 'write-default-styles' template) -->
+
+ <xsl:template name='create-all-inline-styles'>
+
+ <!--** traversee all style trees and their branches collecting style properties **-->
+ <xsl:element name="allstyles">
+ <!--** traversee all office:styles trees beginning with the top-level styles**-->
+ <xsl:for-each select="$office:styles/style:style[not(@style:parent-style-name)]">
+
+ <!--** give out the style properties of the parent node **-->
+ <xsl:call-template name='write-current-and-inherited-style-properties'>
+ <xsl:with-param name="styles-node" select="$office:styles"/>
+ <xsl:with-param name="style-family" select="@style:family"/>
+ <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
+ </xsl:call-template>
+
+ <!--** all office:styles children of the current top-level office:styles **-->
+ <xsl:call-template name='for-all-templates-child-styles'>
+ <xsl:with-param name="parentStyleName" select="@style:name"/>
+ <xsl:with-param name="parentStyleFamily" select="@style:family"/>
+ <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
+ </xsl:call-template>
+
+ <!--** all office:automatic-styles children of the current top-level style **-->
+ <xsl:call-template name='for-all-automatic-child-styles'>
+ <xsl:with-param name="parentStyleName" select="@style:name"/>
+ <xsl:with-param name="parentStyleFamily" select="@style:family"/>
+ <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
+ </xsl:call-template>
+ </xsl:for-each>
+
+ <!--** traversee all office:automatic-styles trees beginning with the top-level styles **-->
+ <xsl:for-each select="$office:automatic-styles/style:style[not(@style:parent-style-name)]">
+ <!--** give out the style properties of the parent node **-->
+ <xsl:call-template name='write-current-and-inherited-style-properties'>
+ <xsl:with-param name="styles-node" select="$office:automatic-styles"/>
+ <xsl:with-param name="style-family" select="@style:family"/>
+ <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
+ </xsl:call-template>
+
+ <!--** all children of the top-level office:automatic-styless **-->
+ <xsl:call-template name='for-all-automatic-child-styles'>
+ <xsl:with-param name="parentStyleName" select="@style:name"/>
+ <xsl:with-param name="parentStyleFamily" select="@style:family"/>
+ <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:element>
+ </xsl:template>
+
+
+
+ <xsl:template name='for-all-templates-child-styles'>
+ <xsl:param name="parentStyleName"/>
+ <xsl:param name="parentStyleFamily"/>
+ <xsl:param name="style-name-tokenized"/>
+
+ <xsl:for-each select="../style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
+ <!--** give out the style properties of the current node **-->
+ <xsl:element name="{$style-name-tokenized}">
+ <xsl:call-template name='write-current-and-inherited-style-properties'>
+ <xsl:with-param name="styles-node" select="$office:styles"/>
+ <xsl:with-param name="style-family" select="@style:family"/>
+ <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
+ </xsl:call-template>
+ </xsl:element>
+
+ <!--** for all template-children of the current office:styles **-->
+ <xsl:call-template name='for-all-templates-child-styles'>
+ <xsl:with-param name="styles-node" select="$office:styles"/>
+ <xsl:with-param name="parentStyleName" select="@style:name"/>
+ <xsl:with-param name="parentStyleFamily" select="@style:family"/>
+ <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
+ </xsl:call-template>
+
+ <!--** for all automatic-children of the current office:styles **-->
+ <xsl:call-template name='for-all-automatic-child-styles'>
+ <xsl:with-param name="styles-node" select="$office:automatic-styles"/>
+ <xsl:with-param name="parentStyleName" select="@style:name"/>
+ <xsl:with-param name="parentStyleFamily" select="@style:family"/>
+ <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
+ </xsl:call-template>
+
+ </xsl:for-each>
+ </xsl:template>
+
+
+
+ <xsl:template name='for-all-automatic-child-styles'>
+ <xsl:param name="styles-node"/>
+ <xsl:param name="parentStyleName"/>
+ <xsl:param name="parentStyleFamily"/>
+ <xsl:param name="style-name-tokenized"/>
+
+ <xsl:for-each select="$office:automatic-styles/style:style[@style:family=$parentStyleFamily and @style:parent-style-name=$parentStyleName]">
+ <!--** give out the style properties of the current node **-->
+ <xsl:element name="{$style-name-tokenized}">
+ <xsl:call-template name='write-current-and-inherited-style-properties'>
+ <xsl:with-param name="styles-node" select="$office:automatic-styles"/>
+ <xsl:with-param name="style-family" select="@style:family"/>
+ <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
+ </xsl:call-template>
+ </xsl:element>
+
+ <!--** for all automatic-children of the current office:automatic-styles **-->
+ <xsl:call-template name='for-all-automatic-child-styles'>
+ <xsl:with-param name="styles-node" select="$office:automatic-styles"/>
+ <xsl:with-param name="parentStyleName" select="@style:name"/>
+ <xsl:with-param name="parentStyleFamily" select="@style:family"/>
+ <xsl:with-param name="style-name-tokenized" select="translate(@style:name, '. %()/\', '')"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:template>
+
+
+ <xsl:template name='write-current-and-inherited-style-properties'>
+ <xsl:param name="style-family"/>
+ <xsl:param name="styles-node"/>
+ <xsl:param name="style-name-tokenized"/>
+
+ <xsl:element name="{$style-name-tokenized}">
+ <xsl:variable name="current-style-name" select="@style:name"/>
+ <xsl:variable name="parent-style-name" select="@style:parent-style-name"/>
+
+ <xsl:variable name="new-property-list">
+ <!--*** COLLECT STYLE ATTRIBUTES (only toplevel) ***-->
+ <xsl:call-template name="write-style-properties">
+ <xsl:with-param name="styleAttributePath" select="$styles-node/style:style[@style:family=$style-family and @style:name=$current-style-name]/style:properties/@*"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <!--*** @End: GIVE OUT All COLLECTED STYLE ATTRIBUTES (only toplevel) ***-->
+ <xsl:when test="string-length($parent-style-name)=0">
+ <!--** if no styleParent is given, the properties are given out at once **-->
+ <xsl:value-of select="normalize-space($new-property-list)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="new-property-names">
+ <xsl:for-each select="$styles-node/style:style[@style:family=$style-family and @style:name=$current-style-name]/style:properties/@*">
+ <xsl:value-of select="name()"/>
+ </xsl:for-each>
+ </xsl:variable>
+ <!--** further attributes of the parent style must be collected **-->
+ <xsl:call-template name="add-parent-style-attributes">
+ <xsl:with-param name="property-name-list" select="$new-property-names"/>
+ <xsl:with-param name="complete-property-list" select="normalize-space($new-property-list)"/>
+ <xsl:with-param name="current-style-name" select="$current-style-name"/>
+ <xsl:with-param name="parent-style-name" select="$parent-style-name"/>
+ <xsl:with-param name="style-family" select="$style-family"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:element>
+ </xsl:template>
+
+
+
+ <xsl:template name="add-parent-style-attributes">
+ <xsl:param name="property-name-list"/>
+ <xsl:param name="complete-property-list"/>
+ <xsl:param name="current-style-name"/>
+ <xsl:param name="parent-style-name"/>
+ <xsl:param name="style-family"/>
+
+ <!--*** New two be added property names will be collected (only one variable per template) ***-->
+ <xsl:variable name="new-property-names">
+ <xsl:call-template name="get-new-style-names">
+ <xsl:with-param name="property-name-list" select="$property-name-list"/>
+ <xsl:with-param name="parent-style-name" select="$parent-style-name"/>
+ <xsl:with-param name="current-style-name" select="$current-style-name"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <!--*** check if the new parent style exist in the office:automatic-styles section (defined by name and family) ***-->
+ <xsl:when test="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$current-style-name]">
+ <!--*** RECURSION: adding new parent style attributes to the current style ***-->
+ <xsl:variable name="new-property-attributes">
+ <xsl:call-template name="get-new-style-attributes">
+ <xsl:with-param name="new-property-names" select="$new-property-names"/>
+ <xsl:with-param name="current-style-name" select="$current-style-name"/>
+ <xsl:with-param name="parent-style-name" select="$parent-style-name"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!--*** End CONDITION: the last style parent has already been executed ***-->
+ <xsl:variable name="new-parent-style-name" select="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/@style:parent-style-name"/>
+ <xsl:choose>
+ <xsl:when test="string-length($new-parent-style-name)=0">
+ <!--** no further parent is found, the given parameter property-node is the final style -->
+ <xsl:value-of select="concat($complete-property-list,$new-property-attributes)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <!--** further attributes of the parent style must be collected **-->
+ <xsl:call-template name="add-parent-style-attributes">
+ <xsl:with-param name="property-name-list" select="concat($property-name-list, $new-property-names)"/>
+ <xsl:with-param name="complete-property-list" select="concat($complete-property-list,$new-property-attributes)"/>
+ <xsl:with-param name="current-style-name" select="$parent-style-name"/>
+ <xsl:with-param name="parent-style-name" select="$new-parent-style-name"/>
+ <xsl:with-param name="style-family" select="$style-family"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <!--** the specific style (defined by name and family) must be found in the office:styles section -->
+ <xsl:otherwise>
+ <!--*** RECURSION: adding new parent style attributes to the current style ***-->
+ <!--*** adding new parent style attributes to the current style ***-->
+ <xsl:variable name="new-property-attributes">
+ <xsl:call-template name="get-new-style-attributes">
+ <xsl:with-param name="new-property-names" select="$new-property-names"/>
+ <xsl:with-param name="current-style-name" select="$current-style-name"/>
+ <xsl:with-param name="parent-style-name" select="$parent-style-name"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <!--*** End CONDITION: the last style parent has already been executed ***-->
+ <xsl:variable name="new-parent-style-name" select="$office:styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/@style:parent-style-name"/>
+ <xsl:choose>
+ <xsl:when test="string-length($new-parent-style-name)=0">
+ <!--** no further parent is found, the given parameter property-node is the final style -->
+ <xsl:value-of select="concat($complete-property-list,$new-property-attributes)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <!--** further attributes of the parent style must be collected ** -->
+ <xsl:call-template name="add-parent-style-attributes">
+ <xsl:with-param name="property-name-list" select="concat($property-name-list, $new-property-names)"/>
+ <xsl:with-param name="complete-property-list" select="concat($complete-property-list,$new-property-attributes)"/>
+ <xsl:with-param name="current-style-name" select="$parent-style-name"/>
+ <xsl:with-param name="parent-style-name" select="$new-parent-style-name"/>
+ <xsl:with-param name="style-family" select="$style-family"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <xsl:template name="get-new-style-names">
+ <xsl:param name="property-name-list"/>
+ <xsl:param name="parent-style-name"/>
+ <xsl:param name="current-style-name"/>
+ <!--** where to find the specific style (defined by name and family) wheter in office:automatic-styles or office:styles section -->
+ <xsl:choose>
+ <!--** if the specific style (defined by name and family) can be found in the office:automatic-styles section -->
+ <xsl:when test="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]">
+ <xsl:variable name="parent-property-node" select="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>
+
+ <xsl:variable name="new-property-name-list">
+ <xsl:for-each select="$parent-property-node/@*[not(contains($property-name-list, name()))]">
+ <xsl:value-of select="name()"/>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:value-of select="$new-property-name-list"/>
+ </xsl:when>
+ <!--** the specific style (defined by name and family) should be found in the office:styles section -->
+ <xsl:otherwise>
+ <xsl:variable name="parent-property-node" select="$office:styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>
+ <xsl:variable name="new-property-name-list">
+ <xsl:for-each select="$parent-property-node/@*[not(contains($property-name-list, name()))]">
+ <xsl:value-of select="name()"/>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:value-of select="$new-property-name-list"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <xsl:template name="get-new-style-attributes">
+ <xsl:param name="new-property-names"/>
+ <xsl:param name="current-style-name"/>
+ <xsl:param name="parent-style-name"/>
+
+ <!--** where to find the specific style (defined by name and family) whether in office:automatic-styles or office:styles section -->
+ <xsl:choose>
+ <!--** if the specific style (defined by name and family) can be found in the office:automatic-styles section -->
+ <xsl:when test="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]">
+ <xsl:variable name="parent-property-node" select="$office:automatic-styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>
+ <xsl:variable name="new-property-name-list">
+ <xsl:call-template name="write-style-properties">
+ <xsl:with-param name="styleAttributePath" select="$parent-property-node/@*[contains($new-property-names, name())]"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="normalize-space($new-property-name-list)"/>
+ </xsl:when>
+ <!--** otherwise the specific style (defined by name and family) should be found in the office:styles section -->
+ <xsl:otherwise>
+ <xsl:variable name="parent-property-node" select="$office:styles/style:style[@style:family='paragraph' and @style:name=$parent-style-name]/style:properties"/>
+ <xsl:variable name="new-property-name-list">
+ <xsl:call-template name="write-style-properties">
+ <xsl:with-param name="styleAttributePath" select="$parent-property-node/@*[contains($new-property-names, name())]"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="normalize-space($new-property-name-list)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+</xsl:stylesheet>
--- /dev/null
+<!--
+
+ The Contents of this file are made available subject to the terms of
+ either of the following licenses
+
+ - GNU Lesser General Public License Version 2.1
+ - Sun Industry Standards Source License Version 1.1
+
+ Sun Microsystems Inc., October, 2000
+
+ GNU Lesser General Public License Version 2.1
+ =============================================
+ Copyright 2000 by Sun Microsystems, Inc.
+ 901 San Antonio Road, Palo Alto, CA 94303, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1, as published by the Free Software Foundation.
+
+ 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., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+
+ Sun Industry Standards Source License Version 1.1
+ =================================================
+ The contents of this file are subject to the Sun Industry Standards
+ Source License Version 1.1 (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.openoffice.org/license.html.
+
+ Software provided under this License is provided on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ See the License for the specific provisions governing your rights and
+ obligations concerning the Software.
+
+ The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+
+ Copyright © 2002 by Sun Microsystems, Inc.
+
+ All Rights Reserved.
+
+ Contributor(s): _______________________________________
+
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:office="http://openoffice.org/2000/office"
+ xmlns:style="http://openoffice.org/2000/style"
+ xmlns:text="http://openoffice.org/2000/text"
+ xmlns:table="http://openoffice.org/2000/table"
+ xmlns:draw="http://openoffice.org/2000/drawing"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:number="http://openoffice.org/2000/datastyle"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:chart="http://openoffice.org/2000/chart"
+ xmlns:dr3d="http://openoffice.org/2000/dr3d"
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:form="http://openoffice.org/2000/form"
+ xmlns:script="http://openoffice.org/2000/script"
+ office:class="text"
+ office:version="1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:meta="http://openoffice.org/2000/meta"
+ xmlns:config="http://openoffice.org/2001/config"
+ xmlns:help="http://openoffice.org/2000/help"
+ xmlns:xt="http://www.jclark.com/xt"
+ xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ exclude-result-prefixes="java">
+
+
+ <xsl:template name="write-style-properties">
+ <xsl:param name="styleAttributePath"/>
+
+ <xsl:choose>
+ <!--+++++ CSS PROPERTIES +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER' or $outputType = 'CSS_INLINED'">
+
+ <xsl:for-each select="$styleAttributePath">
+ <!-- isDebugModeMESSAGE:
+ <xsl:message> Name:<xsl:value-of select="name()"/> Value:<xsl:value-of select="."/></xsl:message> -->
+
+
+ <!-- <!ATTLIST style:properties style:horizontal-pos (from-left|left|center|right|from-inside|inside|outside)#IMPLIED>-->
+ <!-- 2DO: is inside/from-inside also better showable ? -->
+ <!-- !!!! 2DO: Still there have to be placed a <br clear='all'/> to disable the flow!!!!-->
+ <!-- The OOo attribute 'style:number-wrapped-paragraphs' is currently ignored -->
+ <xsl:choose>
+ <xsl:when test='name(.)="style:wrap"'>
+ <xsl:choose>
+ <xsl:when test='.="left"'>
+ <xsl:text>float: right; </xsl:text>
+ </xsl:when>
+ <xsl:when test='.="right"'>
+ <xsl:text>float: left; </xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:when test='name(.) = "style:horizontal-pos"'>
+ <xsl:choose>
+ <xsl:when test='.="left"'>
+ <xsl:text>align: left; </xsl:text>
+ </xsl:when>
+ <xsl:when test='.="right"'>
+ <xsl:text>align: right; </xsl:text>
+ </xsl:when>
+ <xsl:when test='.="center"'>
+ <xsl:text>align: center; </xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+<!-- results into a bad view (overlapped) in Mozilla 1.0
+ <xsl:when test='name(.) = "table:align"'>
+ <xsl:choose>
+ <xsl:when test='.="left"'>
+ <xsl:text>float: right; </xsl:text>
+ </xsl:when>
+ <xsl:when test='.="right"'>
+ <xsl:text>float: left; </xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+-->
+
+ <!-- PADDING for all variations: fo:padding, fo:padding-top, fo:padding-bottom, fo:padding-left, fo:padding-right -->
+ <xsl:when test='contains(name(.),"fo:padding")'>
+ <xsl:text>padding: </xsl:text>
+ <xsl:value-of select="."/>
+ <xsl:text>; </xsl:text>
+ </xsl:when>
+ <!--
+ fo:border
+ fo:border-top
+ fo:border-bottom
+ fo:border-left
+ fo:border-right
+
+ At present, all four borders must be set simultaneously by using either
+ the fo:border property or by attaching all four of the other border
+ properties to an item set element. In the latter case, if one or more
+ of the properties is missing their values are assumed to be none. The
+ only border styles supported are none or hidden, solid, and double. Any
+ other border style specified is displayed as solid. Transparent borders
+ are not supported and the border widths thin, medium, and thick are
+ mapped to lengths. In addition, only some distinct border widths are
+ supported. Unsupported widths are rounded up to the next supported
+ width.
+ If there are no padding properties specified within the same
+ item set element, a default padding is used for sides that have a
+ border. A value of 0cm is used for sides without a border.
+ (cp. wd-so-xml-text.sdw)
+ -->
+
+<!--2DO START: change measurement equally -->
+ <xsl:when test='name(.)="fo:border"'>
+ <xsl:choose>
+ <!-- changing the distance measure: inch to in -->
+ <xsl:when test="contains(., 'ch')">
+ <xsl:text>border-width:</xsl:text><xsl:value-of select="substring-before(.,'ch ')"/><xsl:text>; </xsl:text>
+ <xsl:text>border-style:</xsl:text><xsl:value-of select="substring-before(substring-after(.,'ch '), ' ')"/><xsl:text>; </xsl:text>
+ <xsl:text>border-color:</xsl:text><xsl:value-of select="substring-after(substring-after(.,'ch '), ' ')"/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test="contains(., 'cm')">
+ <xsl:text>border-width:</xsl:text><xsl:value-of select="substring-before(.,' ')"/><xsl:text>; </xsl:text>
+ <xsl:text>border-style:</xsl:text><xsl:value-of select="substring-before(substring-after(.,'cm '), ' ')"/><xsl:text>; </xsl:text>
+ <xsl:text>border-color:</xsl:text><xsl:value-of select="substring-after(substring-after(.,'cm '), ' ')"/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test="contains(., 'pt')">
+ <xsl:text>border-width:</xsl:text><xsl:value-of select="substring-before(.,' ')"/><xsl:text>; </xsl:text>
+ <xsl:text>border-style:</xsl:text><xsl:value-of select="substring-before(substring-after(.,'pt '), ' ')"/><xsl:text>; </xsl:text>
+ <xsl:text>border-color:</xsl:text><xsl:value-of select="substring-after(substring-after(.,'pt '), ' ')"/><xsl:text>; </xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:border-top"'>
+ <xsl:text>border-top: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:border-bottom"'>
+ <xsl:text>border-bottom: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:border-left"'>
+ <xsl:text>border-left: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:border-right"'>
+ <xsl:text>border-right: </xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="style:column-width"'>
+ <xsl:choose>
+ <!-- changing the distance measure: inch to in -->
+ <xsl:when test="contains(., 'ch')">
+ <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test='name(.)="style:row-height"'>
+ <xsl:choose>
+ <!-- changing the distance measure: inch to in -->
+ <xsl:when test="contains(., 'ch')">
+ <xsl:text>height:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>height:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:width"'>
+ <xsl:choose>
+ <!-- changing the distance measure: inch to in -->
+ <xsl:when test="contains(., 'ch')">
+ <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+<!--2DO END: change measurement equally -->
+ <xsl:when test='name(.)="fo:font-style"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="style:font-name"'>
+ <xsl:text>font-family:</xsl:text>
+ <xsl:variable name="content" select="."/>
+ <xsl:value-of select="$office:font-decls/style:font-decl[@style:name=$content]/@fo:font-family"/>
+ <xsl:text>; </xsl:text>
+ <xsl:if test="contains($office:font-decls/style:font-decl[@style:name=$content]/@style:font-style-name, 'Italic')">
+ <xsl:text>font-style:italic; </xsl:text>
+ </xsl:if>
+ <xsl:if test="contains($office:font-decls/style:font-decl[@style:name=$content]/@style:font-style-name, 'Bold')">
+ <xsl:text>font-weight:bold; </xsl:text>
+ </xsl:if>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:font-weight"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:font-size"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:font-family"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:color"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:margin-left"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:margin-right"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:margin-top"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:margin-bottom"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:line-height"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:text-align"'>
+ <!-- IMPORTANT is necessary as table cell value alignment is decided by runtime over the valuetype
+ Otherwise a table cell style-class will ALWAYS be overwritten by the run-time value -->
+ <xsl:choose>
+ <xsl:when test="contains(., 'start')">
+ <xsl:text>text-align:left ! important; </xsl:text>
+ </xsl:when>
+ <xsl:when test="contains(., 'end')">
+ <xsl:text>text-align:right ! important; </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>text-align:</xsl:text><xsl:value-of select='.'/><xsl:text> ! important; </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:text-indent"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="style:text-background-color"'>
+ <xsl:text>background-color:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="fo:background-color"'>
+ <xsl:text>background-color:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="style:background-image"'>
+ <xsl:text>background-image:url(</xsl:text><xsl:value-of select="@xlink:href"/><xsl:text>); </xsl:text>
+ <xsl:choose>
+ <xsl:when test="@style:repeat = 'repeat'">
+ <xsl:text>background-repeat:repeat; </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>background-repeat:no-repeat; </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <!-- text-shadow is a CSS2 feature and yet not common used in user-agents -->
+ <xsl:when test='name(.)="fo:text-shadow"'>
+ <xsl:value-of select="substring-after(name(.), ':')"/><xsl:text>:</xsl:text><xsl:value-of select="."/><xsl:text>; </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="style:text-crossing-out"'>
+ <xsl:if test='not(.="none")'>
+ <xsl:text>text-decoration:line-through; </xsl:text>
+ </xsl:if>
+ </xsl:when>
+ <xsl:when test='name(.)="style:text-underline"'>
+ <xsl:if test='not(.="none")'>
+ <xsl:text>text-decoration:underline; </xsl:text>
+ </xsl:if>
+ </xsl:when>
+ <xsl:when test='name(.)="style:text-position"'>
+ <xsl:if test='contains(., "sub")'>
+ <xsl:text>vertical-align:sub; </xsl:text>
+ </xsl:if>
+ <xsl:if test='contains(., "sup")'>
+ <xsl:text>vertical-align:sup; </xsl:text>
+ </xsl:if>
+ </xsl:when>
+ <!-- isDebugModeMESSAGE:
+ <xsl:otherwise>
+ <xsl:message>No transformation implemented for attribute-typ <xsl:value-of select="name(.)"/></xsl:message>
+ </xsl:otherwise>-->
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:when>
+ <!--+++++ PALM 3.2 SUBSET AND WAP PROPERTIES +++++-->
+ <xsl:otherwise>
+ <xsl:for-each select="$styleAttributePath">
+ <!-- isDebugModeMESSAGE:
+ <xsl:message> Name:<xsl:value-of select="name()"/> Value:<xsl:value-of select="."/></xsl:message> -->
+
+ <!-- BUG WORK AROUND:
+ Due to a bug in the XT Processor, it is not possible to create serveral elements in variable and search over them,
+ after explicit conversion to nodeset
+ This generated sting identifier shall be later changed back to a set of elements
+ -->
+ <xsl:choose>
+ <!--*** FORMAT ATTRIBUTES ***-->
+
+ <!-- Italic -->
+ <xsl:when test='name(.)="fo:font-style"'>
+ <xsl:if test="contains(., 'italic') or contains(., 'oblique')">
+ <xsl:text>italic, </xsl:text>
+ </xsl:if>
+ </xsl:when>
+
+ <!-- Boldface -->
+ <xsl:when test='name(.)="fo:font-weight"'>
+ <xsl:if test="contains(., 'bold') or contains(., 'bolder')">
+ <xsl:text>bold, </xsl:text>
+ </xsl:if>
+ </xsl:when>
+
+ <!-- Underline -->
+ <xsl:when test='name(.)="style:text-underline"'>
+ <xsl:text>underline, </xsl:text>
+ </xsl:when>
+
+ <!-- Alignment -->
+ <xsl:when test='name(.)="fo:text-align"'>
+ <xsl:choose>
+ <xsl:when test="contains(., 'start')">
+ <xsl:text>align:left, </xsl:text>
+ </xsl:when>
+ <xsl:when test="contains(., 'end')">
+ <xsl:text>align:right, </xsl:text>
+ </xsl:when>
+ <xsl:when test="contains(., 'center')">
+ <xsl:text>align:center, </xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:when>
+
+ <!-- strikethrough -->
+ <xsl:when test='name(.)="style:text-crossing-out"'>
+ <xsl:text>strike, </xsl:text>
+ </xsl:when>
+
+ <!-- Font - size (Palm: emulator transformed sizes to available set (e.g. 30 to (probably) 9)-->
+ <xsl:when test='name(.)="fo:font-size"'>
+ <xsl:text>size:</xsl:text><xsl:value-of select="."/><xsl:text>:size, </xsl:text>
+ </xsl:when>
+
+ <!-- Font - Color (PALM: but mostly only 2 available)
+ black (#000000)
+ gray (#808080)(rendered as dark gray)
+ silver (#C0C0C0)(rendered as light gray)
+ white (#FFFFFF)-->
+ <xsl:when test='name(.)="fo:color"'>
+ <xsl:choose>
+ <xsl:when test="contains(. , '#FFFFFF') or contains(. , '#ffffff') or contains(. , 'white') or contains(. , 'WHITE')">
+ <xsl:text>color:#FFFFFF, </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>color:#000000, </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+
+ <!--*** TABLE ATTRIBUTES ***-->
+ <xsl:when test='name(.)="fo:font-size"'>
+ <xsl:text>size:</xsl:text><xsl:value-of select="."/><xsl:text>:size, </xsl:text>
+ </xsl:when>
+ <xsl:when test='name(.)="style:column-width"'>
+ <xsl:choose>
+ <!-- changing the distance measure: inch to in -->
+ <xsl:when test="contains(., 'ch')">
+ <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>:width, </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>:width; </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test='name(.)="style:row-height"'>
+ <xsl:choose>
+ <!-- changing the distance measure: inch to in -->
+ <xsl:when test="contains(., 'ch')">
+ <xsl:text>height:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>:height; </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>height:</xsl:text><xsl:value-of select="."/><xsl:text>:height; </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test='name(.)="style:width"'> <!--earlier fo:width-->
+ <xsl:choose>
+ <!-- changing the distance measure: inch to in -->
+ <xsl:when test="contains(., 'ch')">
+ <xsl:text>width:</xsl:text><xsl:value-of select="substring-before(.,'ch')"/><xsl:text>:width; </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>width:</xsl:text><xsl:value-of select="."/><xsl:text>:width; </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+<!-- 2DO: NAMING CONVENTION variable are written with '-' instead of case-sensitive writing -->
+
+
+
+ <!-- ***** MEASUREMENT CONVERSIONS *****
+
+ * 1 centimeter = 10 mm
+
+ * 1 inch = 25.4 mm
+ While the English have already seen the light (read: the metric system), the US
+ remains loyal to this medieval system.
+
+ * 1 didot point = 0.376065 mm
+ The didot system originated in France but was used in most of Europe
+
+ * 1 pica point = 0.35146 mm
+ The Pica points system was developed in England and is used in Great-Britain and the US.
+
+ * 1 PostScript point = 0.35277138 mm
+ When Adobe created PostScript, they added their own system of points.
+ There are exactly 72 PostScript points in 1 inch.
+
+ * 1 pixel = 0.26458333.. mm (by 96 dpi)
+ Most pictures have the 96 dpi resolution, but the dpi variable may vary by stylesheet parameter
+ -->
+
+
+ <!-- changing measure to mm -->
+ <xsl:template name="convert2mm">
+ <xsl:param name="value"/>
+
+ <xsl:param name="centimeter-in-mm" select="10"/>
+ <xsl:param name="inch-in-mm" select="25.4"/>
+ <xsl:param name="didot-point-in-mm" select="0.376065"/>
+ <xsl:param name="pica-point-in-mm" select="0.35146"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($value, 'cm')">
+ <xsl:value-of select="round(number(substring-before($value,'cm' )) * $centimeter-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'in')">
+ <xsl:value-of select="round(number(substring-before($value,'in' )) * $inch-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'dpt')">
+ <xsl:value-of select="round(number(substring-before($value,'dpt')) * $didot-point-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'ppt')">
+ <xsl:value-of select="round(number(substring-before($value,'ppt')) * $pica-point-in-mm)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- changing measure to cm -->
+ <xsl:template name="convert2cm">
+ <xsl:param name="value"/>
+
+ <xsl:param name="centimeter-in-mm" select="10"/>
+ <xsl:param name="inch-in-mm" select="25.4"/>
+ <xsl:param name="didot-point-in-mm" select="0.376065"/>
+ <xsl:param name="pica-point-in-mm" select="0.35146"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($value, 'mm')">
+ <xsl:value-of select="round(number(substring-before($value, 'mm')) div $centimeter-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'in')">
+ <xsl:value-of select="round(number(substring-before($value, 'in')) div $centimeter-in-mm * $inch-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'dpt')">
+ <xsl:value-of select="round(number(substring-before($value,'dpt')) div $centimeter-in-mm * $didot-point-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'ppt')">
+ <xsl:value-of select="round(number(substring-before($value,'ppt')) div $centimeter-in-mm * $pica-point-in-mm)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- changing measure to inch (cp. section comment) -->
+ <xsl:template name="convert2inch">
+ <xsl:param name="value"/>
+
+ <xsl:param name="centimeter-in-mm" select="10"/>
+ <xsl:param name="inch-in-mm" select="25.4"/>
+ <xsl:param name="didot-point-in-mm" select="0.376065"/>
+ <xsl:param name="pica-point-in-mm" select="0.35146"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($value, 'mm')">
+ <xsl:value-of select="round(number(substring-before($value, 'mm')) div $inch-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'cm')">
+ <xsl:value-of select="round(number(substring-before($value, 'cm')) div $inch-in-mm * $centimeter-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'dpt')">
+ <xsl:value-of select="round(number(substring-before($value,'dpt')) div $inch-in-mm * $didot-point-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'ppt')">
+ <xsl:value-of select="round(number(substring-before($value,'ppt')) div $inch-in-mm * $pica-point-in-mm)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- changing measure to dpt (cp. section comment) -->
+ <xsl:template name="convert2dpt">
+ <xsl:param name="value"/>
+
+ <xsl:param name="centimeter-in-mm" select="10"/>
+ <xsl:param name="inch-in-mm" select="25.4"/>
+ <xsl:param name="didot-point-in-mm" select="0.376065"/>
+ <xsl:param name="pica-point-in-mm" select="0.35146"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($value, 'mm')">
+ <xsl:value-of select="round(number(substring-before($value, 'mm')) div $didot-point-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'cm')">
+ <xsl:value-of select="round(number(substring-before($value, 'cm')) div $didot-point-in-mm * $centimeter-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'in')">
+ <xsl:value-of select="round(number(substring-before($value, 'in')) div $didot-point-in-mm * $inch-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'ppt')">
+ <xsl:value-of select="round(number(substring-before($value,'ppt')) div $didot-point-in-mm * $pica-point-in-mm)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+
+ <!-- changing measure to ppt (cp. section comment) -->
+ <xsl:template name="convert2ppt">
+ <xsl:param name="value"/>
+
+ <xsl:param name="centimeter-in-mm" select="10"/>
+ <xsl:param name="inch-in-mm" select="25.4"/>
+ <xsl:param name="didot-point-in-mm" select="0.376065"/>
+ <xsl:param name="pica-point-in-mm" select="0.35146"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($value, 'mm')">
+ <xsl:value-of select="round(number(substring-before($value, 'mm')) div $pica-point-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'cm')">
+ <xsl:value-of select="round(number(substring-before($value, 'cm')) div $pica-point-in-mm * $centimeter-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'in')">
+ <xsl:value-of select="round(number(substring-before($value, 'in')) div $pica-point-in-mm * $inch-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'dpt')">
+ <xsl:value-of select="round(number(substring-before($value,'dpt')) div $pica-point-in-mm * $didot-point-in-mm)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- changing measure to pixel by via parameter provided dpi (dots per inch) standard factor (cp. section comment) -->
+ <xsl:template name="convert2pixel">
+ <xsl:param name="value"/>
+
+ <xsl:param name="centimeter-in-mm" select="10"/>
+ <xsl:param name="inch-in-mm" select="25.4"/>
+ <xsl:param name="didot-point-in-mm" select="0.376065"/>
+ <xsl:param name="pica-point-in-mm" select="0.35146"/>
+ <xsl:param name="pixel-in-mm" select="$inch-in-mm div $dpi"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($value, 'mm')">
+ <xsl:value-of select="round(number(substring-before($value, 'mm')) div $pixel-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'cm')">
+ <xsl:value-of select="round(number(substring-before($value, 'cm')) div $pixel-in-mm * $centimeter-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'in')">
+ <xsl:value-of select="round(number(substring-before($value, 'in')) div $pixel-in-mm * $inch-in-mm)"/>
+ </xsl:when>
+ <xsl:when test="contains($value, 'dpt')">
+ <xsl:value-of select="round(number(substring-before($value,'dpt')) div $pixel-in-mm * $didot-point-in-mm)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$value"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<!--
+
+ The Contents of this file are made available subject to the terms of
+ either of the following licenses
+
+ - GNU Lesser General Public License Version 2.1
+ - Sun Industry Standards Source License Version 1.1
+
+ Sun Microsystems Inc., October, 2000
+
+ GNU Lesser General Public License Version 2.1
+ =============================================
+ Copyright 2000 by Sun Microsystems, Inc.
+ 901 San Antonio Road, Palo Alto, CA 94303, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1, as published by the Free Software Foundation.
+
+ 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., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+
+ Sun Industry Standards Source License Version 1.1
+ =================================================
+ The contents of this file are subject to the Sun Industry Standards
+ Source License Version 1.1 (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.openoffice.org/license.html.
+
+ Software provided under this License is provided on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ See the License for the specific provisions governing your rights and
+ obligations concerning the Software.
+
+ The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+
+ Copyright © 2002 by Sun Microsystems, Inc.
+
+ All Rights Reserved.
+
+ Contributor(s): _______________________________________
+
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:office="http://openoffice.org/2000/office"
+ xmlns:style="http://openoffice.org/2000/style"
+ xmlns:text="http://openoffice.org/2000/text"
+ xmlns:table="http://openoffice.org/2000/table"
+ xmlns:draw="http://openoffice.org/2000/drawing"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:number="http://openoffice.org/2000/datastyle"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:chart="http://openoffice.org/2000/chart"
+ xmlns:dr3d="http://openoffice.org/2000/dr3d"
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:form="http://openoffice.org/2000/form"
+ xmlns:script="http://openoffice.org/2000/script"
+ office:class="text"
+ office:version="1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:meta="http://openoffice.org/2000/meta"
+ xmlns:config="http://openoffice.org/2001/config"
+ xmlns:help="http://openoffice.org/2000/help"
+ xmlns:xt="http://www.jclark.com/xt"
+ xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ exclude-result-prefixes="java">
+
+
+ <!-- table row handling -->
+ <xsl:include href="table_rows.xsl"/>
+ <!-- table column handling -->
+ <xsl:include href="table_columns.xsl"/>
+ <!-- table cell handling -->
+ <xsl:include href="table_cells.xsl"/>
+
+
+
+ <!-- ******************* -->
+ <!-- *** main table *** -->
+ <!-- ******************* -->
+
+ <xsl:template match="table:table | table:sub-table">
+ <xsl:param name="collectedGlobalData"/>
+
+ <!-- a table will only be created if the "scenario" is active -->
+ <xsl:if test="string-length(table:scenario/@table:is-active) = 0">
+ <!-- collecting all visible "table:table-row" elements of the table -->
+ <xsl:variable name="allVisibleTableRows" select="table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]
+ | table:table-header-rows/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]
+ | table:table-row-group/descendant::table:table-row[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]"/>
+ <xsl:choose>
+ <!-- for all but WAP/WML devices a table border check is done (cp. "check-for-table-border") -->
+ <xsl:when test="not($outputType = 'WML')">
+
+ <!-- As the alignment of a table is by 'align' attribut is deprecated and as the CSS 'float' attribute not well displayed,
+ we do a little trick by encapsulating the table with a aligned 'div' element-->
+ <xsl:variable name="table-alignment" select="$office:automatic-styles/style:style[@style:name = current()/@table:style-name]/style:properties/@table:align"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($table-alignment) != 0">
+ <xsl:element name="div">
+ <xsl:attribute name="align">
+ <xsl:choose>
+ <xsl:when test='$table-alignment="left" or $table-alignment="margins"'>
+ <xsl:text>left</xsl:text>
+ </xsl:when>
+ <xsl:when test='$table-alignment="right"'>
+ <xsl:text>right</xsl:text>
+ </xsl:when>
+ <xsl:when test='$table-alignment="center"'>
+ <xsl:text>center</xsl:text>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:element name="table">
+
+ <xsl:apply-templates select="@table:style-name">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+
+ <!-- workaround, set table border attribut if any cell-border exists
+ <xsl:call-template name="check-for-table-border">
+ <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
+ </xsl:call-template> -->
+ <xsl:call-template name="create-column-style-variable">
+ <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="table">
+ <xsl:apply-templates select="@table:style-name">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+
+ <!-- workaround, set table border attribut if any cell-border exists
+ <xsl:call-template name="check-for-table-border">
+ <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
+ </xsl:call-template> -->
+ <xsl:call-template name="create-column-style-variable">
+ <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- for WML devices only ASCII table are written as tables are not implemented widley.
+ Beginning from 'repeat-write-row' the templates are handled by the table_wml.xsl stylesheet -->
+ <xsl:call-template name="create-column-style-variable">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:template>
+
+
+
+ <xsl:template name="create-column-style-variable">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="allVisibleTableRows"/>
+
+ <!-- all columns of the table -->
+ <xsl:variable name="allTableColumns" select="table:table-column |
+ table:table-column-group/descendant::table:table-column |
+ table:table-header-columns/descendant::table:table-column"/>
+ <!-- allColumnStyleEntries: Containing all columns of the table, hidden and viewed.
+ - if a column is hidden, it contains the hidden attribute, otherwise the style-properties will be stored
+ - if a column is being repeated, each repeated column is explicitly written as entry in this variable.
+ Later (during template "write-cell") the style of the column will be mixed with the cell-style by using
+ the position() of the column entry and comparing it with the iterating cell number. -->
+ <xsl:variable name="allColumnStyleEntries-RTF">
+ <xsl:call-template name="adding-column-styles-entries">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allTableColumns" select="$allTableColumns"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="function-available('xt:node-set')">
+ <xsl:call-template name="create-table">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
+ <xsl:with-param name="allColumnStyleEntries" select="xt:node-set($allColumnStyleEntries-RTF)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="function-available('xalan:nodeset')">
+ <xsl:call-template name="create-table">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allVisibleTableRows" select="$allVisibleTableRows"/>
+ <xsl:with-param name="allColumnStyleEntries" select="xalan:nodeset($allColumnStyleEntries-RTF)"/>
+ </xsl:call-template>
+ </xsl:when>
+ </xsl:choose>
+
+ </xsl:template>
+
+
+
+ <xsl:template name="create-table">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="allVisibleTableRows"/>
+ <xsl:param name="allColumnStyleEntries"/>
+
+
+ <!-- Some Office Calc documents simulate a background by repeating the last cell until end of space
+ (The value of "table:number-columns-repeated" is enourmous). Writing out all these cells would be fatal.
+ Therefore, this global variable shows us the longest row with content.
+
+ Earlier only the viewable columns were listed, but it is easier to handle with all columns:
+ <xsl:variable name="maxRowLength" select="count($allColumnStyleEntries/column-style-entry[not(@column-hidden-flag)])"/> -->
+ <xsl:variable name="maxRowLength" select="count($allColumnStyleEntries/column-style-entry)"/>
+
+
+ <!--isDebugMode-START-->
+ <xsl:if test="$isDebugMode">
+ <xsl:message>maxRowLength: <xsl:value-of select="$maxRowLength"/></xsl:message>
+ <xsl:variable name="numberOfHiddenColumns" select="count($allColumnStyleEntries/column-style-entry[@column-hidden-flag])"/>
+ <xsl:message>numberOfHiddenColumns: <xsl:value-of select="$numberOfHiddenColumns"/></xsl:message>
+ <xsl:call-template name="table-debug-allColumnStyleEntries">
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ </xsl:call-template>
+ </xsl:if>
+ <!--isDebugMode-END-->
+ <xsl:choose>
+ <xsl:when test="$outputType = 'WML'">
+ <!-- matching all rows - we can not use xsl:apply-template with a node-set parameter as by a bug in XT (James Clark)
+ (here: allColumnStyleEntries) will be interpreted as a result tree fragment, where no search expression (XPath) can be used
+ 2DO:CHECK WITH XALAN-->
+ <xsl:for-each select="$allVisibleTableRows">
+ <xsl:call-template name="wml-repeat-write-row">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="number-rows-repeated" select="@table:number-rows-repeated"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- matching all rows - we can not use xsl:apply-template with a node-set parameter as by a bug in XT (James Clark)
+ (here: allColumnStyleEntries) will be interpreted as a result tree fragment, where no search expression (XPath) can be used
+ 2DO:CHECK WITH XALAN -->
+ <xsl:for-each select="$allVisibleTableRows">
+ <xsl:call-template name="repeat-write-row">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="number-rows-repeated" select="@table:number-rows-repeated"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+
+
+ <!-- **************************** -->
+ <!-- *** HELPER: table border *** -->
+ <!-- **************************** -->
+
+ <!-- only one table border for HTML4 or CSS devices which contain one or more 'fo:border-top' attributes (pars pro toto, if one exist the other usually exist, too) -->
+ <!-- this was a work-around for the netscape 4.xx but not longer necessary for Mozilla -->
+ <xsl:template name="check-for-table-border">
+ <xsl:param name="allVisibleTableRows"/>
+
+ <xsl:variable name="startTime">
+ <xsl:if test="$isDebugMode and not($isJavaDisabled)">
+ <xsl:choose>
+ <xsl:when test="function-available('system:current-time-millis')">
+ <xsl:value-of select="system:current-time-millis()"/>
+ </xsl:when>
+ <xsl:when test="function-available('java:java.lang.System.currentTimeMillis')">
+ <xsl:value-of select="java:java.lang.System.currentTimeMillis()"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:variable>
+
+ <!-- checks if one cell (table:table-cell) of the rows of this table (allVisibleTableRows) contains a border style (i.e. fo:border-top)
+ If only one single border element exist, the whole table will gets pre-defined borders (simple heuristic for better browser display) -->
+ <xsl:if test="$allVisibleTableRows/table:table-cell[@table:style-name=/*/*/style:style[style:properties/@fo:border-top]/@style:name]">
+ <xsl:attribute name="border">1</xsl:attribute>
+ <xsl:attribute name="bordercolor">#000000</xsl:attribute>
+ <xsl:attribute name="cellpadding">2</xsl:attribute>
+ <xsl:attribute name="cellspacing">0</xsl:attribute>
+ <xsl:attribute name="page-break-inside">page-break-inside:avoid</xsl:attribute>
+ </xsl:if>
+
+
+ <!-- check the time for borderchecking (debug)-->
+ <xsl:if test="$isDebugMode and not($isJavaDisabled)">
+ <xsl:variable name="endTime">
+ <xsl:choose>
+ <xsl:when test="function-available('system:current-time-millis')">
+ <xsl:value-of select="system:current-time-millis()"/>
+ </xsl:when>
+ <xsl:when test="function-available('java:java.lang.System.currentTimeMillis')">
+ <xsl:value-of select="java:java.lang.System.currentTimeMillis()"/>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:message>Time for checking BorderStyle: <xsl:value-of select="($endTime - $startTime)"/> ms</xsl:message>
+ </xsl:if>
+ </xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<!--
+
+ The Contents of this file are made available subject to the terms of
+ either of the following licenses
+
+ - GNU Lesser General Public License Version 2.1
+ - Sun Industry Standards Source License Version 1.1
+
+ Sun Microsystems Inc., October, 2000
+
+ GNU Lesser General Public License Version 2.1
+ =============================================
+ Copyright 2000 by Sun Microsystems, Inc.
+ 901 San Antonio Road, Palo Alto, CA 94303, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1, as published by the Free Software Foundation.
+
+ 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., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+
+ Sun Industry Standards Source License Version 1.1
+ =================================================
+ The contents of this file are subject to the Sun Industry Standards
+ Source License Version 1.1 (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.openoffice.org/license.html.
+
+ Software provided under this License is provided on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ See the License for the specific provisions governing your rights and
+ obligations concerning the Software.
+
+ The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+
+ Copyright © 2002 by Sun Microsystems, Inc.
+
+ All Rights Reserved.
+
+ Contributor(s): _______________________________________
+
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:office="http://openoffice.org/2000/office"
+ xmlns:style="http://openoffice.org/2000/style"
+ xmlns:text="http://openoffice.org/2000/text"
+ xmlns:table="http://openoffice.org/2000/table"
+ xmlns:draw="http://openoffice.org/2000/drawing"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:number="http://openoffice.org/2000/datastyle"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:chart="http://openoffice.org/2000/chart"
+ xmlns:dr3d="http://openoffice.org/2000/dr3d"
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:form="http://openoffice.org/2000/form"
+ xmlns:script="http://openoffice.org/2000/script"
+ office:class="text"
+ office:version="1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:meta="http://openoffice.org/2000/meta"
+ xmlns:config="http://openoffice.org/2001/config"
+ xmlns:help="http://openoffice.org/2000/help"
+ xmlns:xt="http://www.jclark.com/xt"
+ xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ exclude-result-prefixes="java">
+
+
+ <!-- *********************************** -->
+ <!-- *** write repeating table cells *** -->
+ <!-- *********************************** -->
+
+
+ <!-- matching cells to give out -> covered table cells are not written out -->
+ <xsl:template match="table:table-cell">
+ <xsl:param name="collectedGlobalData"/>
+ <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
+ <xsl:param name="allColumnStyleEntries"/>
+ <xsl:param name="maxRowLength"/>
+
+ <xsl:if test="$isDebugMode">
+ <xsl:message>
+--------------> table:table-cell has been entered with node value: <xsl:value-of select="."/></xsl:message>
+ <xsl:message>table:number-columns-repeated: -<xsl:value-of select="@table:number-columns-repeated"/>-</xsl:message>
+ </xsl:if>
+
+ <xsl:call-template name="create-column-position-variable">
+ <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ </xsl:call-template>
+
+ </xsl:template>
+
+
+
+ <xsl:template name="create-column-position-variable">
+ <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
+ <xsl:param name="allColumnStyleEntries"/>
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="maxRowLength"/>
+
+ <!-- column position needed for styles, esp. for column-hidden-flag -->
+ <xsl:variable name="preceding-columns">
+ <xsl:for-each select="preceding-sibling::*">
+ <xsl:element name="quantity">
+ <xsl:choose>
+ <xsl:when test="string-length(@table:number-columns-repeated) = 0">1</xsl:when>
+ <xsl:otherwise><xsl:value-of select="@table:number-columns-repeated"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:element>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="function-available('xt:node-set')">
+ <xsl:call-template name="create-table-cell">
+ <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ <xsl:with-param name="column-position" select="sum(xt:node-set($preceding-columns)/quantity) + 1"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="function-available('xalan:nodeset')">
+ <xsl:call-template name="create-table-cell">
+ <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ <xsl:with-param name="column-position" select="sum(xalan:nodeset($preceding-columns)/quantity) + 1"/>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="NodeSetFunctionNotAvailable"/>
+ <xsl:call-template name="create-table-cell"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <xsl:template name="create-table-cell">
+ <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
+ <xsl:param name="allColumnStyleEntries"/>
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="maxRowLength"/>
+ <xsl:param name="column-position"/>
+
+
+ <xsl:if test="$isDebugMode">
+ <xsl:message>NEW VALUE: column-position: -<xsl:value-of select="$column-position"/>-</xsl:message>
+ </xsl:if>
+
+
+ <!-- a hidden column will give out nothing -->
+ <xsl:if test="not($allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag)">
+ <xsl:choose>
+ <!-- when the columns are not repeated the next column-positions raises up to 1, otherwise up to the amount of repeated columns -->
+ <xsl:when test="@table:number-columns-repeated">
+ <!-- writes multiple entries of a cell -->
+ <xsl:call-template name="repeat-write-cell">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="column-position" select="$column-position"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ <xsl:with-param name="number-columns-repeated" select="@table:number-columns-repeated"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- writes an entry of a cell -->
+ <xsl:call-template name="write-cell">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="column-position" select="$column-position"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ </xsl:template>
+
+
+
+ <xsl:template name="repeat-write-cell">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="allColumnStyleEntries"/>
+ <xsl:param name="column-position"/>
+ <xsl:param name="maxRowLength"/>
+ <xsl:param name="number-columns-repeated"/>
+
+ <xsl:choose>
+ <!-- 2DO: This is the current workaround against the background simulation by an 'endless' repeating cell -->
+ <xsl:when test="$number-columns-repeated > 1 and $maxRowLength > $column-position">
+
+ <xsl:if test="$isDebugMode">
+ <xsl:message>+++++++++ starting cell writing +++++++++</xsl:message>
+ <xsl:message>number-columns-repeated: -<xsl:value-of select="$number-columns-repeated"/>-</xsl:message>
+ <xsl:message>maxRowLength: -<xsl:value-of select="$maxRowLength"/>-</xsl:message>
+ <xsl:message>column-position: -<xsl:value-of select="$column-position"/>-</xsl:message>
+ </xsl:if>
+
+ <!-- writes an entry of a cell -->
+ <xsl:call-template name="write-cell">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="column-position" select="$column-position"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ </xsl:call-template>
+ <!-- repeat calling this method until all elements written out -->
+ <xsl:if test="$isDebugMode">
+ <xsl:message>+++++++++ cell repetition +++++++++</xsl:message>
+ </xsl:if>
+ <xsl:call-template name="repeat-write-cell">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="column-position" select="$column-position + 1"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ <xsl:with-param name="number-columns-repeated" select="$number-columns-repeated - 1"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- 2DO: This is the current workaround against the background simulation by an 'endless' repeating cell -->
+ <!-- When the maxRowLength is reached a last entry of a cell is written -->
+ <xsl:call-template name="write-cell">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="column-position" select="$column-position"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <xsl:template name="write-cell">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="allColumnStyleEntries"/>
+ <xsl:param name="column-position"/>
+ <xsl:param name="maxRowLength"/>
+
+
+ <xsl:if test="$isDebugMode">
+ <xsl:message>WriteTest -> If nothing between '-' write cell -<xsl:value-of select="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag"/>-</xsl:message>
+ </xsl:if>
+
+ <xsl:if test="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag">
+ <xsl:if test="$isDebugMode">
+ <xsl:message>TABLE COLUMN is hidden!</xsl:message>
+ </xsl:if>
+ </xsl:if>
+
+ <xsl:choose>
+ <!-- a hidden column will give out nothing -->
+ <xsl:when test="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@column-hidden-flag">
+ <xsl:if test="$isDebugMode">
+ <xsl:message>TABLE COLUMN is hidden!</xsl:message>
+ </xsl:if>
+ </xsl:when>
+
+ <!-- NOT a hidden column -->
+ <xsl:otherwise>
+
+ <!-- a table is a table header, when it has a "table:table-header-rows" ancestor -->
+ <xsl:variable name="tableDataType">
+ <xsl:choose>
+ <xsl:when test="ancestor::table:table-header-rows">
+ <xsl:text>th</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>td</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER'">
+ <xsl:element name="{$tableDataType}">
+
+ <xsl:if test="$isDebugMode">
+ <xsl:message>
+*****************************************'<xsl:value-of select="$tableDataType"/>' element has been added!</xsl:message>
+ </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>
+
+
+
+ <!-- *** the cell-style *** -->
+ <!-- The cell style has no conclusion with the column style, so we switch the order/priorities due to browser issues
+
+ The cell-style depends on two attributes:
+
+ 1) table:style-name - the style properties of cell. When they exist, a default alignement (cp. below) will be added for the
+ case of no alignment in the style exist.
+
+ 2) table:value-type - the value type of the table-cell giving the default alignments.
+ By default a string value is left aligned, all other are aligned:right.
+ -->
+ <xsl:choose>
+ <xsl:when test="@table:style-name">
+ <xsl:attribute name="style">
+
+ <!-- CELL-STYLE: alignment by table:value-type (without existing table:style-name)-->
+ <xsl:variable name="cellStyle" select="$collectedGlobalData/allstyles/*[name()=current()/@table:style-name]"/>
+ <xsl:choose>
+ <xsl:when test="string-length($cellStyle) > 0 and not(contains($cellStyle, 'text-align'))">
+ <!-- CELL-STYLE: alignment by table:value-type -->
+ <!-- no alignment in the cell style, the alignment based on the table:value-type will be added -->
+ <xsl:choose>
+ <xsl:when test="@table:value-type and not(@table:value-type = 'string')">
+ <xsl:value-of select="concat($collectedGlobalData/allstyles/*[name()=current()/@table:style-name], 'text-align:right; ')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat($collectedGlobalData/allstyles/*[name()=current()/@table:style-name], 'text-align:left; ')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- CELL-STYLE: alignment by table:value-type -->
+ <!-- no CSS style properties exist, only alignment from the table:value-type will be used -->
+ <xsl:choose>
+ <xsl:when test="@table:value-type and not(@table:value-type = 'string')">text-align:right; </xsl:when>
+ <xsl:otherwise>text-align:left; </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <!-- column-style (disjunct of cell style -->
+ <!-- 2DO: only absolut styles are supported, relative styles (i.e. 'style:rel-column-width' e.g. with value "8933*" are ignored.
+ Issue: browsers (not sure if CSS) does not support the '*' relationship, only the '%', where the sum is always '100'!
+ For this, it is easier to work on with the absolute values, instead of calculating the values for 100% -->
+ <xsl:value-of select="$allColumnStyleEntries/column-style-entry[position()=$column-position]"/>
+ </xsl:attribute>
+ <!-- CELL-STYLE: table:style-name -->
+ <xsl:attribute name="class">
+ <xsl:value-of select="translate(@table:style-name, '. %()/\', '')"/>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="style">
+ <!-- CELL-STYLE: alignment by table:value-type (without existing table:style-name)-->
+ <!-- no table:style-name exist, only alignment from the table:value-type will be used -->
+ <xsl:choose>
+ <xsl:when test="@table:value-type and not(@table:value-type = 'string')">
+ text-align:right;
+ </xsl:when>
+ <xsl:otherwise>
+ text-align:left;
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:choose>
+ <!-- In case of no cell content a non-breakable space will be inserted
+ to make the browser show the table-cell grid -->
+ <xsl:when test="not(child::text()) and not(child::*)">
+ <xsl:text>  </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- *** the column-style *** -->
+ <!-- the column style has no conclusion with the cell style, so we switch the order/priorities due to browser issues-->
+ <xsl:element name="span">
+ <xsl:attribute name="class">
+ <xsl:value-of select="$allColumnStyleEntries/column-style-entry[position() = $column-position]/@style-name"/>
+ </xsl:attribute>
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:element>
+ </xsl:when>
+
+ <!--+++++ HTML 4.0 INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_INLINED'">
+ <xsl:element name="{$tableDataType}">
+
+ <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:attribute name="style">
+ <!-- cell-style -->
+ <xsl:value-of select="$collectedGlobalData/allstyles/*[name()=current()/@table:style-name]"/>
+ <!-- column-style -->
+ <xsl:value-of select="$allColumnStyleEntries/column-style-entry[position()=$column-position]"/>
+ <!-- TABLE:VALUE-TYPE - the value of a table-cell will be aligned left by default only exlicit non-string is aligned:right-->
+ <xsl:choose>
+ <xsl:when test="@table:value-type and not(@table:value-type = 'string')">
+ <xsl:text>text-align:right;</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>text-align:left;</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+
+ <!--   is a non-breakable space, necessary to make to the browser show the table-cell grid -->
+ <xsl:if test="not(child::text()) and not(child::*)">  </xsl:if>
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:element>
+ </xsl:when>
+ <!--+++++ PALM INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'PALM'">
+ <xsl:element name="{$tableDataType}">
+ <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>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ </xsl:element>
+ </xsl:when>
+ <!--+++++ WML WAY +++++-->
+ <xsl:when test="$outputType = 'WML'">
+ <xsl:choose>
+ <xsl:when test="not($allColumnStyleEntries/column-style-entry[last() = $column-position])">
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ <xsl:text>, </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:apply-templates>
+ <xsl:text>; </xsl:text>
+ <xsl:element name="br"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+</xsl:stylesheet>
--- /dev/null
+<!--
+
+ The Contents of this file are made available subject to the terms of
+ either of the following licenses
+
+ - GNU Lesser General Public License Version 2.1
+ - Sun Industry Standards Source License Version 1.1
+
+ Sun Microsystems Inc., October, 2000
+
+ GNU Lesser General Public License Version 2.1
+ =============================================
+ Copyright 2000 by Sun Microsystems, Inc.
+ 901 San Antonio Road, Palo Alto, CA 94303, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1, as published by the Free Software Foundation.
+
+ 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., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+
+ Sun Industry Standards Source License Version 1.1
+ =================================================
+ The contents of this file are subject to the Sun Industry Standards
+ Source License Version 1.1 (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.openoffice.org/license.html.
+
+ Software provided under this License is provided on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ See the License for the specific provisions governing your rights and
+ obligations concerning the Software.
+
+ The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+
+ Copyright © 2002 by Sun Microsystems, Inc.
+
+ All Rights Reserved.
+
+ Contributor(s): _______________________________________
+
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:office="http://openoffice.org/2000/office"
+ xmlns:style="http://openoffice.org/2000/style"
+ xmlns:text="http://openoffice.org/2000/text"
+ xmlns:table="http://openoffice.org/2000/table"
+ xmlns:draw="http://openoffice.org/2000/drawing"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:number="http://openoffice.org/2000/datastyle"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:chart="http://openoffice.org/2000/chart"
+ xmlns:dr3d="http://openoffice.org/2000/dr3d"
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:form="http://openoffice.org/2000/form"
+ xmlns:script="http://openoffice.org/2000/script"
+ office:class="text"
+ office:version="1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:meta="http://openoffice.org/2000/meta"
+ xmlns:config="http://openoffice.org/2001/config"
+ xmlns:help="http://openoffice.org/2000/help"
+ xmlns:xt="http://www.jclark.com/xt"
+ xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ exclude-result-prefixes="java">
+
+
+ <!-- ******************************************** -->
+ <!-- *** Create table columns style variable *** -->
+ <!-- ******************************************** -->
+
+ <xsl:template name="adding-column-styles-entries">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="allTableColumns"/>
+
+ <xsl:for-each select="$allTableColumns">
+
+ <xsl:variable name="column-style-entry" select="$collectedGlobalData/allstyles/*[name() = translate(current()/@table:style-name, '. %()/\', '')]"/>
+ <xsl:choose>
+ <xsl:when test="not(@table:number-columns-repeated)">
+ <!-- writes an entry of a column in the columns-variable -->
+ <xsl:call-template name="adding-column-style-entry">
+ <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
+ </xsl:call-template>
+ </xsl:when>
+ <!-- No higher repetition of cells greater than 4 for the last and second last column -->
+ <!-- a hack for the sample document 'Waehrungsumrechner.sxc having 230 repeated columns in the second last column -->
+ <!-- ??? <xsl:when test="(position() = last() or (position() = (last() - 1)) and @table:number-columns-repeated < 5)"> ???-->
+ <xsl:when test="position() = last() or position() = (last() - 1)">
+ <xsl:if test="@table:number-columns-repeated < 5">
+ <!-- writes an entry of a column in the columns-variable -->
+ <xsl:call-template name="repeat-adding-column-style-entry">
+ <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
+ <xsl:with-param name="number-columns-repeated" select="1"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- repeated colums will be written explicit several times in the variable-->
+ <xsl:call-template name="repeat-adding-column-style-entry">
+ <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
+ <xsl:with-param name="number-columns-repeated" select="@table:number-columns-repeated"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:template>
+
+
+ <!-- WRITES THE REPEATED COLUMN STYLE EXPLICIT AS AN ELEMENT IN THE COLUMNS-VARIABLE -->
+ <xsl:template name="repeat-adding-column-style-entry">
+ <xsl:param name="column-style-entry"/>
+ <xsl:param name="number-columns-repeated"/>
+
+ <xsl:choose>
+ <xsl:when test="$number-columns-repeated > 1">
+ <!-- writes an entry of a column in the columns-variable -->
+ <xsl:call-template name="adding-column-style-entry">
+ <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
+ </xsl:call-template>
+ <!-- repeat calling this method until all elements written out -->
+ <xsl:call-template name="repeat-adding-column-style-entry">
+ <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
+ <xsl:with-param name="number-columns-repeated" select="$number-columns-repeated - 1"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- writes an entry of a column in the columns-variable -->
+ <xsl:call-template name="adding-column-style-entry">
+ <xsl:with-param name="column-style-entry" select="$column-style-entry"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- THE COLUMN-STYLE WRITE-PATTERN FOR EACH COLUMN WRITTEN IN A VARIABLE -->
+ <xsl:template name="adding-column-style-entry">
+ <xsl:param name="column-style-entry"/>
+
+ <xsl:element name="column-style-entry">
+ <xsl:choose>
+ <xsl:when test="@table:visibility = 'collapse' or @table:visibility = 'filter'">
+ <xsl:attribute name="column-hidden-flag">true</xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="table:style-name" select="translate(@table:style-name, '. %()/\', '')"/>
+ <xsl:attribute name="style-name"><xsl:value-of select="$table:style-name"/></xsl:attribute>
+ <xsl:value-of select="$column-style-entry"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:element>
+ </xsl:template>
+
+
+
+ <!--isDebugMode-START-->
+ <!-- giving out the 'allColumnStyle' variable:
+ For each 'column-style-entry' of the 'allColumnStyleEntries' variable the style-name is given out.
+ In case of 'column-hidden-flag' attribute the text 'Column is hidden is given out.-->
+ <xsl:template name="table-debug-allColumnStyleEntries">
+ <xsl:param name="allColumnStyleEntries"/>
+
+ <!-- debug output as table summary attribut in html -->
+ <xsl:attribute name="summary">
+ <xsl:call-template name="table-debug-column-out">
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ </xsl:call-template>
+ </xsl:attribute>
+ <!-- debug output to console -->
+ <xsl:message>
+ <xsl:call-template name="table-debug-column-out">
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ </xsl:call-template>
+ </xsl:message>
+ </xsl:template>
+
+
+ <xsl:template name="table-debug-column-out">
+ <xsl:param name="allColumnStyleEntries"/>
+ <xsl:text>
+ DebugInformation: For each 'column-style-entry' of the 'allColumnStyleEntries' variable the style-name is given out.
+ In case of 'column-hidden-flag' attribute the text 'column is hidden' is given out.
+ </xsl:text>
+ <xsl:for-each select="$allColumnStyleEntries/column-style-entry">
+ <xsl:choose>
+ <xsl:when test="@column-hidden-flag">
+ <xsl:text> </xsl:text><xsl:value-of select="@style-name"/><xsl:text>column is hidden</xsl:text><xsl:text>
+ </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text> </xsl:text><xsl:value-of select="@style-name"/><xsl:text> = </xsl:text><xsl:value-of select="."/><xsl:text>
+ </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ </xsl:template>
+ <!--isDebugMode-END-->
+
+</xsl:stylesheet>
--- /dev/null
+<!--
+
+ The Contents of this file are made available subject to the terms of
+ either of the following licenses
+
+ - GNU Lesser General Public License Version 2.1
+ - Sun Industry Standards Source License Version 1.1
+
+ Sun Microsystems Inc., October, 2000
+
+ GNU Lesser General Public License Version 2.1
+ =============================================
+ Copyright 2000 by Sun Microsystems, Inc.
+ 901 San Antonio Road, Palo Alto, CA 94303, USA
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License version 2.1, as published by the Free Software Foundation.
+
+ 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., 59 Temple Place, Suite 330, Boston,
+ MA 02111-1307 USA
+
+
+ Sun Industry Standards Source License Version 1.1
+ =================================================
+ The contents of this file are subject to the Sun Industry Standards
+ Source License Version 1.1 (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.openoffice.org/license.html.
+
+ Software provided under this License is provided on an "AS IS" basis,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ See the License for the specific provisions governing your rights and
+ obligations concerning the Software.
+
+ The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+
+ Copyright © 2002 by Sun Microsystems, Inc.
+
+ All Rights Reserved.
+
+ Contributor(s): _______________________________________
+
+-->
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:office="http://openoffice.org/2000/office"
+ xmlns:style="http://openoffice.org/2000/style"
+ xmlns:text="http://openoffice.org/2000/text"
+ xmlns:table="http://openoffice.org/2000/table"
+ xmlns:draw="http://openoffice.org/2000/drawing"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:number="http://openoffice.org/2000/datastyle"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:chart="http://openoffice.org/2000/chart"
+ xmlns:dr3d="http://openoffice.org/2000/dr3d"
+ xmlns:math="http://www.w3.org/1998/Math/MathML"
+ xmlns:form="http://openoffice.org/2000/form"
+ xmlns:script="http://openoffice.org/2000/script"
+ office:class="text"
+ office:version="1.0"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:meta="http://openoffice.org/2000/meta"
+ xmlns:config="http://openoffice.org/2001/config"
+ xmlns:help="http://openoffice.org/2000/help"
+ xmlns:xt="http://www.jclark.com/xt"
+ xmlns:system="http://www.jclark.com/xt/java/java.lang.System"
+ xmlns:xalan="http://xml.apache.org/xalan"
+ xmlns:java="http://xml.apache.org/xslt/java"
+ exclude-result-prefixes="java">
+
+
+
+ <!-- ********************************************* -->
+ <!-- *** write (explicit) repeating table rows *** -->
+ <!-- ********************************************* -->
+
+ <xsl:template name="repeat-write-row">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="allColumnStyleEntries"/>
+ <xsl:param name="number-rows-repeated" select="1"/>
+ <xsl:param name="maxRowLength"/>
+
+ <xsl:choose>
+ <!-- write an entry of a row and repeat calling this method until all elements are written out -->
+ <xsl:when test="$number-rows-repeated > 1 and (table:table-cell/text() or table:table-cell/*)">
+ <xsl:call-template name="write-row">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ </xsl:call-template>
+
+ <!-- 2DO: take variable from the output of repeated write-row and iterate giving out the variable -->
+ <xsl:call-template name="repeat-write-row">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ <xsl:with-param name="number-rows-repeated" select="$number-rows-repeated - 1"/>
+ </xsl:call-template>
+ </xsl:when>
+ <!-- write a single entry of a row -->
+ <xsl:otherwise>
+ <xsl:call-template name="write-row">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <xsl:template name="write-row">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="allColumnStyleEntries"/>
+ <xsl:param name="maxRowLength"/>
+
+
+ <xsl:element name="tr">
+ <!-- writing the style of the row -->
+ <xsl:call-template name='add-style-properties'>
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ </xsl:call-template>
+
+ <xsl:if test="$isDebugMode">
+ <xsl:message>
+*************************'tr' element has been added!</xsl:message>
+ </xsl:if>
+
+ <xsl:apply-templates select="table:table-cell">
+ <xsl:with-param name="collectedGlobalData" select="$collectedGlobalData"/>
+ <xsl:with-param name="allColumnStyleEntries" select="$allColumnStyleEntries"/>
+ <xsl:with-param name="maxRowLength" select="$maxRowLength"/>
+ </xsl:apply-templates>
+
+ </xsl:element>
+ </xsl:template>
+
+
+ <!-- **************************** -->
+ <!-- *** HELPER: table styles *** -->
+ <!-- **************************** -->
+
+ <xsl:template name="add-style-properties">
+ <xsl:param name="collectedGlobalData"/>
+ <xsl:param name="allColumnStyleEntries"/>
+ <xsl:param name="node-position"/>
+
+ <xsl:choose>
+ <!--+++++ CSS (CASCADING STLYE SHEET) HEADER STYLE WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_HEADER'">
+ <xsl:attribute name="class">
+ <xsl:value-of select="translate(@table:style-name, '. %()/\', '')"/>
+ </xsl:attribute>
+ </xsl:when>
+
+ <!--+++++ HTML 4.0 INLINED WAY +++++-->
+ <xsl:when test="$outputType = 'CSS_INLINED'">
+ <xsl:attribute name="style">
+ <xsl:value-of select="$collectedGlobalData/allstyles/*[name()=current()/@table:style-name]"/>
+ </xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Pdf class simply outputs the PDF file with the
+ * content-type 'application/pdf' enabling web browsers with a PDF viewer
+ * plugin to view the PDF file inside the browser.
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Pdf extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $this->_mimepart->getContents(),
+ 'status' => array(),
+ 'type' => 'application/pdf'
+ )
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Php class renders out syntax-highlighted PHP code in
+ * HTML format.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Php extends Horde_Mime_Viewer_Source
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => true,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ $ret = $this->_renderInline();
+
+ // Need Horde headers for CSS tags.
+ reset($ret);
+ Horde::startBuffer();
+ require $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc';
+ echo $ret[key($ret)]['data'];
+ require $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
+ $ret[key($ret)]['data'] = Horde::endBuffer();
+
+ return $ret;
+ }
+
+ /**
+ * Return the rendered inline version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInline()
+ {
+ $code = $this->_mimepart->getContents();
+ if (strpos($code, '<?php') === false) {
+ $text = str_replace('<?php ', '', highlight_string('<?php ' . $code, true));
+ } else {
+ $text = highlight_string($code, true);
+ }
+ $text = trim(str_replace(array("\n", '<br />'), array('', "\n"), $text));
+ $text = $this->_lineNumber($text);
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $text,
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Plain class renders out plain text with URLs made
+ * into hyperlinks (if viewing inline).
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Anil Madhavapeddy <anil@recoil.org>
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Plain extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => true,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ $text = $this->_mimepart->getContents();
+ $charset = $this->_mimepart->getCharset();
+
+ /* Check for 'flowed' text data. */
+ if ($this->_mimepart->getContentTypeParameter('format') == 'flowed') {
+ $text = $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp'));
+ }
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => '<html><body><tt>' . Horde_Text_Filter::filter($text, 'text2html', array(
+ 'charset' => $charset,
+ 'parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL
+ )) . '</tt></body></html>',
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $charset
+ )
+ );
+ }
+
+ /**
+ * Return the rendered inline version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInline()
+ {
+ $text = Horde_String::convertCharset($this->_mimepart->getContents(), $this->_mimepart->getCharset());
+
+ /* Check for 'flowed' text data. */
+ $data = ($this->_mimepart->getContentTypeParameter('format') == 'flowed')
+ ? $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp'))
+ : $text;
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $data,
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+
+ /**
+ * Format flowed text for HTML output.
+ *
+ * @param string $text The text to format.
+ * @param boolean $delsp Was text created with DelSp formatting?
+ *
+ * @return string The formatted text.
+ */
+ protected function _formatFlowed($text, $delsp = null)
+ {
+ $flowed = new Horde_Text_Flowed($this->_mimepart->replaceEOL($text, "\n"), $this->_mimepart->getCharset());
+ $flowed->setMaxLength(0);
+ if (!is_null($delsp)) {
+ $flowed->setDelSp($delsp);
+ }
+ return $flowed->toFixed();
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Rar class renders out the contents of .rar archives
+ * in HTML format.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Anil Madhavapeddy <anil@recoil.org>
+ * @author Michael Cochrane <mike@graftonhall.co.nz>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Rar extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => true,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Metadata for the current viewer/data.
+ *
+ * @var array
+ */
+ protected $_metadata = array(
+ 'compressed' => true,
+ 'embedded' => false,
+ 'forceinline' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ $ret = $this->_renderInfo();
+ if (!empty($ret)) {
+ reset($ret);
+ $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
+ }
+ return $ret;
+ }
+
+ /**
+ * Return the rendered information about the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _renderInfo()
+ {
+ $contents = $this->_mimepart->getContents();
+
+ $rar = Horde_Compress::factory('rar');
+ $rarData = $rar->decompress($contents);
+
+ $charset = $GLOBALS['registry']->getCharset();
+ $fileCount = count($rarData);
+
+ $name = $this->_mimepart->getName(true);
+ if (empty($name)) {
+ $name = _("unnamed");
+ }
+
+ $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
+ '<table><tr><td align="left"><pre>' .
+ Horde_Text_Filter::filter(_("Archive Name") . ': ' . $name, 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
+ Horde_Text_Filter::filter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
+ Horde_Text_Filter::filter(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) .
+ "\n\n" .
+ Horde_Text_Filter::filter(
+ Horde_String::pad(_("File Name"), 50, ' ', STR_PAD_RIGHT) .
+ Horde_String::pad(_("Attributes"), 10, ' ', STR_PAD_LEFT) .
+ Horde_String::pad(_("Size"), 10, ' ', STR_PAD_LEFT) .
+ Horde_String::pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) .
+ Horde_String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) .
+ Horde_String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT),
+ 'space2html',
+ array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
+ str_repeat('-', 109) . "\n";
+
+ foreach ($rarData as $val) {
+ $ratio = empty($val['size'])
+ ? 0
+ : 100 * ($val['csize'] / $val['size']);
+
+ $text .= Horde_Text_Filter::filter(
+ Horde_String::pad($val['name'], 50, ' ', STR_PAD_RIGHT) .
+ Horde_String::pad($val['attr'], 10, ' ', STR_PAD_LEFT) .
+ Horde_String::pad($val['size'], 10, ' ', STR_PAD_LEFT) .
+ Horde_String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT) .
+ Horde_String::pad($val['method'], 10, ' ', STR_PAD_LEFT) .
+ Horde_String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT),
+ 'space2html',
+ array('encode' => true, 'encode_all' => true)
+ ) . "\n";
+ }
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => nl2br($text . str_repeat('-', 106) . "\n</pre></td></tr></table>"),
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $charset
+ )
+ );
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Report class is a wrapper used to load the
+ * appropriate Horde_Mime_Viewer for multipart/report data (RFC 3462).
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Report extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * Return the underlying MIME Viewer for this part.
+ *
+ * @return mixed A Horde_Mime_Viewer object, or false if not found.
+ */
+ protected function _getViewer()
+ {
+ if (!($type = $this->_mimepart->getContentTypeParameter('report-type'))) {
+ /* This is a broken RFC 3462 message, since 'report-type' is
+ * mandatory. Try to determine the report-type by looking at the
+ * sub-type of the second body part. */
+ $parts = $this->_mimepart->getParts();
+ if (!isset($parts[1])) {
+ return false;
+ }
+ $type = $parts[1]->getSubType();
+ }
+
+ $viewer = Horde_Mime_Viewer::factory($this->_mimepart, 'message/' . Horde_String::lower($type));
+ if ($viewer) {
+ $viewer->setParams($this->_params);
+ }
+
+ return $viewer;
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Rfc822 class renders out messages from the
+ * message/rfc822 content type.
+ *
+ * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Rfc822 extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => true,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $this->_mimepart->getContents(),
+ 'status' => array(),
+ 'type' => 'text/plain; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+
+ /**
+ * Return the rendered information about the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInfo()
+ {
+ /* Get the text of the part. Since we need to look for the end of
+ * the headers by searching for the CRLFCRLF sequence, use
+ * getCanonicalContents() to make sure we are getting the text with
+ * CRLF's. */
+ $text = $this->_mimepart->getContents(array('canonical' => true));
+ if (empty($text)) {
+ return array();
+ }
+
+ /* Search for the end of the header text (CRLFCRLF). */
+ $text = substr($text, 0, strpos($text, "\r\n\r\n"));
+
+ /* Get the list of headers now. */
+ $headers = Horde_Mime_Headers::parseHeaders($text);
+
+ $header_array = array(
+ 'date' => _("Date"),
+ 'from' => _("From"),
+ 'to' => _("To"),
+ 'cc' => _("Cc"),
+ 'bcc' => _("Bcc"),
+ 'reply-to' => _("Reply-To"),
+ 'subject' => _("Subject")
+ );
+ $header_output = array();
+
+ foreach ($header_array as $key => $val) {
+ $hdr = $headers->getValue($key);
+ if (!empty($hdr)) {
+ $header_output[] = '<strong>' . $val . ':</strong> ' . htmlspecialchars($hdr);
+ }
+ }
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => empty($header_output) ? '' : ('<div class="fixed mimeHeaders">' . Horde_Text_Filter::filter(implode("<br />\n", $header_output), 'emails') . '</div>'),
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Richtext class renders out HTML text from
+ * text/richtext content tags, (RFC 1896 [7.1.3]).
+ *
+ * A minimal richtext implementation is one that simply converts "<lt>" to
+ * "<", converts CRLFs to SPACE, converts <nl> to a newline according to
+ * local newline convention, removes everything between a <comment> command
+ * and the next balancing </comment> command, and removes all other
+ * formatting commands (all text enclosed in angle brackets).
+ *
+ * We implement the following tags:
+ * <bold>, <italic>, <fixed>, <smaller>, <bigger>, <underline>, <center>,
+ * <flushleft>, <flushright>, <indent>, <subscript>, <excerpt>, <paragraph>,
+ * <signature>, <comment>, <no-op>, <lt>, <nl>
+ *
+ * The following tags are implemented differently than described in the RFC
+ * (due to limitations in HTML output):
+ * <heading> - Output as centered, bold text.
+ * <footing> - Output as centered, bold text.
+ * <np> - Output as paragraph break.
+ *
+ * The following tags are NOT implemented:
+ * <indentright>, <outdent>, <outdentright>, <samepage>, <iso-8859-X>,
+ * <us-ascii>,
+ *
+ * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Richtext extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => true,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $this->_toHTML(),
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $this->_mimepart->getCharset()
+ )
+ );
+ }
+
+ /**
+ * Return the rendered inline version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInline()
+ {
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => Horde_String::convertCharset($this->_toHTML(), $this->_mimepart->getCharset()),
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+
+ /**
+ * Convert richtext to HTML.
+ *
+ * @return string The converted HTML string.
+ */
+ protected function _toHTML()
+ {
+ $text = trim($this->_mimepart->getContents());
+ if ($text == '') {
+ return array();
+ }
+
+ /* We add space at the beginning and end of the string as it will
+ * make some regular expression checks later much easier (so we
+ * don't have to worry about start/end of line characters). */
+ $text = ' ' . $text . ' ';
+
+ /* Remove everything between <comment> tags. */
+ $text = preg_replace('/<comment.*>.*<\/comment>/Uis', '', $text);
+
+ /* Remove any unrecognized tags in the text. We don't need <no-op>
+ * in $tags since it doesn't do anything anyway. All <comment> tags
+ * have already been removed. */
+ $tags = '<bold><italic><fixed><smaller><bigger><underline><center><flushleft><flushright><indent><subscript><excerpt><paragraph><signature><lt><nl>';
+ $text = strip_tags($text, $tags);
+
+ /* <lt> becomes a '<'. CRLF becomes a SPACE. */
+ $text = str_ireplace(array('<lt>', "\r\n"), array('<', ' '), $text);
+
+ /* We try to protect against bad stuff here. */
+ $text = @htmlspecialchars($text, ENT_QUOTES, $this->_mimepart->getCharset());
+
+ /* <nl> becomes a newline (<br />);
+ * <np> becomes a paragraph break (<p />). */
+ $text = str_ireplace(array('<nl>', '<np>'), array('<br />', '<p />'), $text);
+
+ /* Now convert the known tags to html. Try to remove any tag
+ * parameters to stop people from trying to pull a fast one. */
+ $replace = array(
+ '/(?<!<)<bold.*>(.*)<\/bold>/Uis' => '<span style="font-weight: bold">\1</span>',
+ '/(?<!<)<italic.*>(.*)<\/italic>/Uis' => '<span style="font-style: italic">\1</span>',
+ '/(?<!<)<fixed.*>(.*)<\/fixed>/Uis' => '<font face="fixed">\1</font>',
+ '/(?<!<)<smaller.*>(.*)<\/smaller>/Uis' => '<span style="font-size: smaller">\1</span>',
+ '/(?<!<)<bigger.*>(.*)<\/bigger>/Uis' => '<span style="font-size: larger">\1</span>',
+ '/(?<!<)<underline.*>(.*)<\/underline>/Uis' => '<span style="text-decoration: underline">\1</span>',
+ '/(?<!<)<center.*>(.*)<\/center>/Uis' => '<div align="center">\1</div>',
+ '/(?<!<)<flushleft.*>(.*)<\/flushleft>/Uis' => '<div align="left">\1</div>',
+ '/(?<!<)<flushright.*>(.*)<\/flushright>/Uis' => '<div align="right">\1</div>',
+ '/(?<!<)<indent.*>(.*)<\/indent>/Uis' => '<blockquote>\1</blockquote>',
+ '/(?<!<)<excerpt.*>(.*)<\/excerpt>/Uis' => '<cite>\1</cite>',
+ '/(?<!<)<subscript.*>(.*)<\/subscript>/Uis' => '<sub>\1</sub>',
+ '/(?<!<)<superscript.*>(.*)<\/superscript>/Uis' => '<sup>\1</sup>',
+ '/(?<!<)<heading.*>(.*)<\/heading>/Uis' => '<br /><div align="center" style="font-weight: bold">\1</div><br />',
+ '/(?<!<)<footing.*>(.*)<\/footing>/Uis' => '<br /><div align="center" style="font-weight: bold">\1</div><br />',
+ '/(?<!<)<paragraph.*>(.*)<\/paragraph>/Uis' => '<p>\1</p>',
+ '/(?<!<)<signature.*>(.*)<\/signature>/Uis' => '<address>\1</address>'
+ );
+ $text = preg_replace(array_keys($replace), array_values($replace), $text);
+
+ /* Now we remove the leading/trailing space we added at the start. */
+ $text = substr($text, 1, -1);
+
+ /* Wordwrap. */
+ $text = str_replace(array("\t", ' ', "\n "), array(' ', ' ', "\n "), $text);
+ if ($text[0] == ' ') {
+ $text = ' ' . substr($text, 1);
+ }
+
+ return '<p style="font-size:100%;font-family:Lucida Console,Courier,Courier New;">' . nl2br($text) . '</p>';
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Rpm class renders out lists of files in RPM
+ * packages by using the rpm tool to query the package.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Anil Madhavapeddy <anil@recoil.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Rpm extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => true,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Metadata for the current viewer/data.
+ *
+ * @var array
+ */
+ protected $_metadata = array(
+ 'compressed' => true,
+ 'embedded' => false,
+ 'forceinline' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ $ret = $this->_renderInfo();
+ if (!empty($ret)) {
+ reset($ret);
+ $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
+ }
+ return $ret;
+ }
+
+ /**
+ * Return the rendered information about the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInfo()
+ {
+ /* Check to make sure the viewer program exists. */
+ if (!isset($this->_conf['location']) ||
+ !file_exists($this->_conf['location'])) {
+ return array();
+ }
+
+ $data = '';
+ $tmp_rpm = Horde::getTempFile('horde_rpm');
+
+ file_put_contents($tmp_rpm, $this->_mimepart->getContents());
+
+ $fh = popen($this->_conf['location'] . " -qip $tmp_rpm 2>&1", 'r');
+ while (($rc = fgets($fh, 8192))) {
+ $data .= $rc;
+ }
+ pclose($fh);
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => '<pre>' . htmlentities($data) . '</pre>',
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Rtf class renders out Rich Text Format documents in
+ * HTML format by using the UnRTF package.
+ *
+ * UnRTF package: http://www.gnu.org/software/unrtf/unrtf.html
+ *
+ * Copyright 2007 Duck <duck@obala.net>
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Rtf extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ /* Check to make sure the viewer program exists. */
+ if (!isset($this->_conf['location']) ||
+ !file_exists($this->_conf['location'])) {
+ return array();
+ }
+
+ $tmp_rtf = Horde::getTempFile('rtf');
+ $tmp_output = Horde::getTempFile('rtf');
+
+ file_put_contents($tmp_rtf, $this->_mimepart->getContents());
+
+ exec($this->_conf['location'] . " $tmp_rtf > $tmp_output");
+
+ if (file_exists($tmp_output)) {
+ $data = file_get_contents($tmp_output);
+ } else {
+ $data = _("Unable to translate this RTF document");
+ }
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $data,
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Security class is a wrapper used to load the
+ * appropriate Horde_Mime_Viewer for secure multipart messages (defined by RFC
+ * 1847). This class handles multipart/signed and multipart/encrypted data.
+ *
+ * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Security extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * Return the underlying MIME Viewer for this part.
+ *
+ * @return mixed A Horde_Mime_Viewer object, or false if not found.
+ */
+ protected function _getViewer()
+ {
+ if (!($protocol = $this->_mimepart->getContentTypeParameter('protocol'))) {
+ return false;
+ }
+
+ $viewer = Horde_Mime_Viewer::factory($this->_mimepart, $protocol);
+ if ($viewer) {
+ $viewer->setParams($this->_params);
+ }
+ return $viewer;
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Simple class renders out plain text without any
+ * modifications.
+ *
+ * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Simple extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $this->_mimepart->getContents(),
+ 'status' => array(),
+ 'type' => 'text/plain; charset=' . $this->_mimepart->getCharset()
+ )
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Smil renders SMIL documents to very basic HTML.
+ *
+ * Copyright 2006-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Jan Schneider <jan@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Smil extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * Handle for the XML parser object.
+ *
+ * @var resource
+ */
+ protected $_parser;
+
+ /**
+ * String buffer to hold the generated content
+ *
+ * @var string
+ */
+ protected $_content;
+
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Metadata for the current viewer/data.
+ *
+ * @var array
+ */
+ protected $_metadata = array(
+ 'compressed' => false,
+ 'embedded' => false,
+ 'forceinline' => true
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ $this->_content = '';
+
+ /* Create a new parser and set its default properties. */
+ $this->_parser = xml_parser_create();
+ xml_set_object($this->_parser, $this);
+ xml_set_element_handler($this->_parser, '_startElement', '_endElement');
+ xml_set_character_data_handler($this->_parser, '_defaultHandler');
+ xml_parse($this->_parser, $this->_mimepart->getContents(), true);
+ xml_parser_free($this->_parser);
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $this->_content,
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+
+ /**
+ * User-defined function callback for start elements.
+ *
+ * @param object $parser Handle to the parser instance.
+ * @param string $name The name of this XML element.
+ * @param array $attrs List of this element's attributes.
+ */
+ protected function _startElement($parser, $name, $attrs)
+ {
+ switch ($name) {
+ case 'IMG':
+ if (isset($attrs['SRC'])) {
+ $this->_content .= '<img src="' . htmlspecialchars($attrs['SRC']) . '" />';
+ }
+ break;
+ }
+ }
+
+ /**
+ * User-defined function callback for end elements.
+ *
+ * @param object $parser Handle to the parser instance.
+ * @param string $name The name of this XML element.
+ */
+ protected function _endElement($parser, $name)
+ {
+ }
+
+ /**
+ * User-defined function callback for character data.
+ *
+ * @param object $parser Handle to the parser instance.
+ * @param string $data String of character data.
+ */
+ protected function _defaultHandler($parser, $data)
+ {
+ $data = trim($data);
+ if (!empty($data)) {
+ $this->_content .= ' ' . htmlspecialchars($data);
+ }
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Source class is a class for any viewer that wants
+ * to provide line numbers to extend.
+ *
+ * Copyright 1999-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Source extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * Add line numbers to a block of code.
+ *
+ * @param string $code The code to number.
+ *
+ * @return string The code with line numbers added.
+ */
+ protected function _lineNumber($code, $linebreak = "\n")
+ {
+ $html = array('<table class="lineNumbered" cellspacing="0"><tr><th>');
+ for ($l = 1, $lines = substr_count($code, $linebreak) + 1; $l <= $lines; ++$l) {
+ $html[] = sprintf('<a id="l%s" href="#l%s">%s</a><br />', $l, $l, $l);
+ }
+ return implode("\n", $html) . '</th><td><div>' . $code . '</div></td></tr></table>';
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Srchighlite class renders out various content in HTML
+ * format by using the GNU source-highlight package.
+ *
+ * Source-highlight: http://www.gnu.org/software/src-highlite/
+ * Tested with v3.1.3
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Mike Cochrane <mike@graftonhall.co.nz>
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Srchighlite extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ $ret = $this->_renderInline();
+
+ reset($ret);
+ $ret[key($ret)]['data'] = '<html><body>' .
+ $ret[key($ret)]['data'] .
+ '</body></html>';
+
+ return $ret;
+ }
+
+ /**
+ * Return the rendered inline version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInline()
+ {
+ /* Check to make sure the viewer program exists. */
+ if (!isset($this->_conf['location']) ||
+ !file_exists($this->_conf['location'])) {
+ return array();
+ }
+
+ /* Create temporary files for Webcpp. */
+ $tmpin = Horde::getTempFile('SrcIn');
+ $tmpout = Horde::getTempFile('SrcOut', false);
+
+ /* Write the contents of our buffer to the temporary input file. */
+ file_put_contents($tmpin, $this->_mimepart->getContents());
+
+ /* Determine the language from the mime type. */
+ $lang = $this->_typeToLang($this->_mimepart->getType());
+
+ /* Execute Source-Highlite. */
+ exec($this->_conf['location'] . " --src-lang $lang --out-format html --input $tmpin --output $tmpout");
+ $results = file_get_contents($tmpout);
+ unlink($tmpout);
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $results,
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+
+ /**
+ * Attempts to determine what mode to use for the source-highlight
+ * program from a MIME type.
+ *
+ * @param string $type The MIME type.
+ *
+ * @return string The mode to use.
+ */
+ protected function _typeToLang($type)
+ {
+ switch ($type) {
+ case 'application/x-javascript':
+ return 'js';
+
+ case 'application/x-perl':
+ return 'perl';
+
+ case 'application/x-php':
+ case 'x-extension/phps':
+ case 'x-extension/php3s':
+ case 'application/x-httpd-php':
+ case 'application/x-httpd-php3':
+ case 'application/x-httpd-phps':
+ return 'php';
+
+ case 'application/x-python':
+ return 'python';
+
+ case 'application/x-ruby':
+ return 'ruby';
+
+ case 'application/x-sh':
+ case 'application/x-shellscript':
+ return 'sh';
+
+ case 'application/x-tcl':
+ return 'tcl';
+
+ case 'application/xml':
+ case 'text/xml':
+ return 'xml';
+
+ case 'text/cpp':
+ case 'text/x-c++src':
+ case 'text/x-c++hdr':
+ return 'cpp';
+
+ case 'text/css':
+ case 'x-extension/css':
+ return 'css';
+
+ case 'text/diff':
+ case 'text/x-diff':
+ case 'text/x-patch':
+ return 'diff';
+
+ case 'text/x-chdr':
+ case 'text/x-csrc':
+ return 'c';
+
+ case 'text/x-emacs-lisp':
+ return 'lisp';
+
+ case 'text/x-fortran':
+ case 'x-extension/f77':
+ case 'x-extension/f90':
+ case 'x-extension/for':
+ case 'x-extension/ftn':
+ return 'fortran';
+
+ case 'text/x-java':
+ return 'java';
+
+ case 'text/x-pascal':
+ return 'pascal';
+
+ case 'text/x-sql':
+ return 'sql';
+
+ case 'text/x-tex':
+ return 'tex';
+
+ case 'x-extension/asm':
+ return 'asm';
+
+ case 'x-extension/bat':
+ return 'batch';
+
+ case 'x-extension/cs':
+ return 'csharp';
+
+ case 'x-extension/vb':
+ case 'x-extension/vba':
+ return 'vbs';
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Tgz class renders out plain or gzipped tarballs in
+ * HTML.
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Anil Madhavapeddy <anil@recoil.org>
+ * @author Michael Cochrane <mike@graftonhall.co.nz>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Tgz extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => true,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * The list of compressed subtypes.
+ *
+ * @var array
+ */
+ protected $_gzipSubtypes = array(
+ 'x-compressed-tar', 'tgz', 'x-tgz', 'gzip', 'x-gzip',
+ 'x-gzip-compressed', 'x-gtar'
+ );
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Mime_Part $mime_part Reference to an object with the
+ * information to be rendered.
+ * @param array $conf Configuration specific to the
+ * driver.
+ */
+ public function __construct($mime_part, $conf = array())
+ {
+ parent::__construct($mime_part, $conf);
+
+ $this->_metadata['compressed'] = in_array($mime_part->getSubType(), $this->_gzipSubtypes);
+ }
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _render()
+ {
+ $ret = $this->_renderInfo();
+ if (!empty($ret)) {
+ reset($ret);
+ $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] .
+ '</body></html>';
+ }
+ return $ret;
+ }
+
+ /**
+ * Return the rendered information about the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _renderInfo()
+ {
+ /* Currently, can't do anything without tar file. */
+ $subtype = $this->_mimepart->getSubType();
+ if (in_array($subtype, array('gzip', 'x-gzip', 'x-gzip-compressed'))) {
+ return array();
+ }
+
+ $contents = $this->_mimepart->getContents();
+
+ /* Decompress gzipped files. */
+ if (in_array($subtype, $this->_gzipSubtypes)) {
+ $gzip = Horde_Compress::factory('gzip');
+ $contents = $gzip->decompress($contents);
+ }
+
+ /* Obtain the list of files/data in the tar file. */
+ $tar = Horde_Compress::factory('tar');
+ $tarData = $tar->decompress($contents);
+
+ $charset = $GLOBALS['registry']->getCharset();
+ $fileCount = count($tarData);
+
+ $name = $this->_mimepart->getName(true);
+ if (empty($name)) {
+ $name = _("unnamed");
+ }
+
+ $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
+ '<table><tr><td align="left"><pre>' .
+ Horde_Text_Filter::filter(_("Archive Name") . ': ' . $name, 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
+ Horde_Text_Filter::filter(_("Archive File Size") . ': ' . strlen($contents) . ' bytes', 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) . "\n" .
+ Horde_Text_Filter::filter(sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount), 'space2html', array('charset' => $charset, 'encode' => true, 'encode_all' => true)) .
+ "\n\n" .
+ Horde_Text_Filter::filter(
+ str_pad(_("File Name"), 62, ' ', STR_PAD_RIGHT) .
+ str_pad(_("Attributes"), 15, ' ', STR_PAD_LEFT) .
+ str_pad(_("Size"), 10, ' ', STR_PAD_LEFT) .
+ str_pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT),
+ 'space2html',
+ array('charset' => $charset, 'encode' => true, 'encode_all' => true)
+ ) . "\n" .
+ str_repeat('-', 106) . "\n";
+
+ foreach ($tarData as $val) {
+ $text .= Horde_Text_Filter::filter(
+ str_pad($val['name'], 62, ' ', STR_PAD_RIGHT) .
+ str_pad($val['attr'], 15, ' ', STR_PAD_LEFT) .
+ str_pad($val['size'], 10, ' ', STR_PAD_LEFT) .
+ str_pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT),
+ 'space2html',
+ array('charset' => $charset, 'encode' => true, 'encode_all' => true)
+ ) . "\n";
+ }
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => nl2br($text . str_repeat('-', 106) . "\n</pre></td></tr></table>"),
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $charset
+ )
+ );
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Tnef class allows MS-TNEF attachments to be
+ * displayed.
+ *
+ * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Jan Schneider <jan@horde.org>
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => true,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Metadata for the current viewer/data.
+ *
+ * @var array
+ */
+ protected $_metadata = array(
+ 'compressed' => true,
+ 'embedded' => false,
+ 'forceinline' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _render()
+ {
+ $ret = $this->_renderInfo();
+ if (!empty($ret)) {
+ reset($ret);
+ $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
+ }
+ return $ret;
+ }
+
+ /**
+ * Return the rendered information about the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _renderInfo()
+ {
+ $tnef = Horde_Compress::factory('tnef');
+ $info = $tnef->decompress($this->_mimepart->getContents());
+
+ $data = '<table border="1">';
+ if (empty($info)) {
+ $data .= '<tr><td>' . _("MS-TNEF Attachment contained no data.") . '</td></tr>';
+ } else {
+ $data .= '<tr><td>' . _("Name") . '</td><td>' . _("Mime Type") . '</td></tr>';
+ foreach ($info as $part) {
+ $data .= '<tr><td>' . $part['name'] . '</td><td>' . $part['type'] . '/' . $part['subtype'] . '</td></tr>';
+ }
+ }
+ $data .= '</table>';
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $data,
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Vcard class renders out vCards in HTML format.
+ *
+ * Copyright 2002-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Jan Schneider <jan@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Vcard extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => true,
+ 'raw' => false
+ );
+
+ /**
+ * URL that can be used as a callback for displaying images.
+ *
+ * @var Horde_Url
+ */
+ protected $_imageUrl;
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ $ret = $this->_renderInline();
+
+ if (!empty($ret)) {
+ reset($ret);
+ Horde::startBuffer();
+ include $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc';
+ echo $ret[key($ret)]['data'];
+ include $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
+ $ret[key($ret)]['data'] = Horde::endBuffer();
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Return the rendered inline version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _renderInline()
+ {
+ global $registry, $prefs, $notification;
+
+ $app = false;
+ $data = $this->_mimepart->getContents();
+ $html = '';
+ $import_msg = null;
+ $title = _("vCard");
+
+ $iCal = new Horde_iCalendar();
+ if (!$iCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
+ $notification->push(_("There was an error reading the contact data."), 'horde.error');
+ }
+
+ if (Horde_Util::getFormData('import') &&
+ Horde_Util::getFormData('source') &&
+ $registry->hasMethod('contacts/import')) {
+ $source = Horde_Util::getFormData('source');
+ $count = 0;
+ foreach ($iCal->getComponents() as $c) {
+ if ($c instanceof Horde_iCalendar_vcard) {
+ try {
+ $contacts = $registry->call('contacts/import', array($c, null, $source));
+ ++$count;
+ } catch (Horde_Exception $e) {
+ $notification->push(_("There was an error importing the contact data:") . ' ' . $e->getMessage(), 'horde.error');
+ }
+ }
+ }
+ $notification->push(sprintf(ngettext(
+ "%d contact was successfully added to your address book.",
+ "%d contacts were successfully added to your address book.",
+ $count),
+ $count),
+ 'horde.success');
+ }
+
+ $html .= '<table cellspacing="1" border="0" cellpadding="1">';
+
+ foreach ($iCal->getComponents() as $i => $vc) {
+ if ($i > 0) {
+ $html .= '<tr><td colspan="2"> </td></tr>';
+ }
+
+ $html .= '<tr><td colspan="2" class="header">';
+ $fullname = $vc->getAttributeDefault('FN', false);
+ if ($fullname !== false) {
+ $html .= $fullname;
+ }
+ $html .= '</td></tr>';
+
+ $n = $vc->printableName();
+ if (!empty($n)) {
+ $html .= $this->_row(_("Name"), $n);
+ }
+
+ $aliases = $vc->getAttributeValues('ALIAS');
+ if (!is_a($aliases, 'PEAR_Error')) {
+ $html .= $this->_row(_("Alias"), implode("\n", $aliases));
+ }
+ $birthdays = $vc->getAttributeValues('BDAY');
+ if (!is_a($birthdays, 'PEAR_Error')) {
+ $birthday = new Horde_Date($birthdays[0]);
+ $html .= $this->_row(
+ _("Birthday"),
+ $birthday->strftime($prefs->getValue('date_format')));
+ }
+
+ $photos = $vc->getAllAttributes('PHOTO');
+ foreach ($photos as $p => $photo) {
+ if (isset($photo['params']['VALUE']) &&
+ Horde_String::upper($photo['params']['VALUE']) == 'URI') {
+ $html .= $this->_row(_("Photo"),
+ '<img src="' . htmlspecialchars($photo['value']) . '" />',
+ false);
+ } elseif (isset($photo['params']['ENCODING']) &&
+ Horde_String::upper($photo['params']['ENCODING']) == 'B' &&
+ isset($photo['params']['TYPE'])) {
+ if ($GLOBALS['browser']->hasFeature('datauri') === true ||
+ $GLOBALS['browser']->hasFeature('datauri') >= strlen($photo['value'])) {
+ $html .= $this->_row(_("Photo"),
+ '<img src="data:' . htmlspecialchars($photo['params']['TYPE'] . ';base64,' . $photo['value']) . '" />',
+ false);
+ } elseif ($this->_imageUrl) {
+ $html .= $this->_row(_("Photo"),
+ '<img src="' . htmlspecialchars($this->_imageUrl->add(array('c' => $i, 'p' => $p))) . '" />',
+ false);
+ }
+ }
+ }
+
+ $labels = $vc->getAllAttributes('LABEL');
+ foreach ($labels as $label) {
+ if (isset($label['params']['TYPE'])) {
+ if (!is_array($label['params']['TYPE'])) {
+ $label['params']['TYPE'] = array($label['params']['TYPE']);
+ }
+ } else {
+ $label['params']['TYPE'] = array_keys($label['params']);
+ }
+ $types = array();
+ foreach ($label['params']['TYPE'] as $type) {
+ switch(Horde_String::upper($type)) {
+ case 'HOME':
+ $types[] = _("Home Address");
+ break;
+
+ case 'WORK':
+ $types[] = _("Work Address");
+ break;
+
+ case 'DOM':
+ $types[] = _("Domestic Address");
+ break;
+
+ case 'INTL':
+ $types[] = _("International Address");
+ break;
+
+ case 'POSTAL':
+ $types[] = _("Postal Address");
+ break;
+
+ case 'PARCEL':
+ $types[] = _("Parcel Address");
+ break;
+
+ case 'PREF':
+ $types[] = _("Preferred Address");
+ break;
+ }
+ }
+ if (!count($types)) {
+ $types = array(_("Address"));
+ }
+ $html .= $this->_row(implode('/', $types), $label['value']);
+ }
+
+ $adrs = $vc->getAllAttributes('ADR');
+ foreach ($adrs as $item) {
+ if (isset($item['params']['TYPE'])) {
+ if (!is_array($item['params']['TYPE'])) {
+ $item['params']['TYPE'] = array($item['params']['TYPE']);
+ }
+ } else {
+ $item['params']['TYPE'] = array_keys($item['params']);
+ }
+ $address = $item['values'];
+ $a = array();
+ if (isset($address[VCARD_ADR_STREET])) {
+ $a[] = $address[VCARD_ADR_STREET];
+ }
+ if (isset($address[VCARD_ADR_LOCALITY])) {
+ $a[] = $address[VCARD_ADR_LOCALITY];
+ }
+ if (isset($address[VCARD_ADR_REGION])) {
+ $a[] = $address[VCARD_ADR_REGION];
+ }
+ if (isset($address[VCARD_ADR_POSTCODE])) {
+ $a[] = $address[VCARD_ADR_POSTCODE];
+ }
+ if (isset($address[VCARD_ADR_COUNTRY])) {
+ $a[] = $address[VCARD_ADR_COUNTRY];
+ }
+ $types = array();
+ foreach ($item['params']['TYPE'] as $type) {
+ switch(Horde_String::upper($type)) {
+ case 'HOME':
+ $types[] = _("Home Address");
+ break;
+
+ case 'WORK':
+ $types[] = _("Work Address");
+ break;
+
+ case 'DOM':
+ $types[] = _("Domestic Address");
+ break;
+
+ case 'INTL':
+ $types[] = _("International Address");
+ break;
+
+ case 'POSTAL':
+ $types[] = _("Postal Address");
+ break;
+
+ case 'PARCEL':
+ $types[] = _("Parcel Address");
+ break;
+
+ case 'PREF':
+ $types[] = _("Preferred Address");
+ break;
+ }
+ }
+ if (!count($types)) {
+ $types = array(_("Address"));
+ }
+ $html .= $this->_row(implode('/', $types), implode("\n", $a));
+ }
+
+ $numbers = $vc->getAllAttributes('TEL');
+
+ foreach ($numbers as $number) {
+ if (isset($number['params']['TYPE'])) {
+ if (!is_array($number['params']['TYPE'])) {
+ $number['params']['TYPE'] = array($number['params']['TYPE']);
+ }
+ foreach ($number['params']['TYPE'] as $type) {
+ $number['params'][Horde_String::upper($type)] = true;
+ }
+ }
+ if (isset($number['params']['FAX'])) {
+ $html .= $this->_row(_("Fax"), $number['value']);
+ } else {
+ if (isset($number['params']['HOME'])) {
+ $html .= $this->_row(_("Home Phone"),
+ $number['value']);
+ } elseif (isset($number['params']['WORK'])) {
+ $html .= $this->_row(_("Work Phone"),
+ $number['value']);
+ } elseif (isset($number['params']['CELL'])) {
+ $html .= $this->_row(_("Cell Phone"),
+ $number['value']);
+ } else {
+ $html .= $this->_row(_("Phone"),
+ $number['value']);
+ }
+ }
+ }
+
+ $addresses = $vc->getAllAttributes('EMAIL');
+ $emails = array();
+ foreach ($addresses as $address) {
+ if (isset($address['params']['TYPE'])) {
+ if (!is_array($address['params']['TYPE'])) {
+ $address['params']['TYPE'] = array($address['params']['TYPE']);
+ }
+ foreach ($address['params']['TYPE'] as $type) {
+ $address['params'][Horde_String::upper($type)] = true;
+ }
+ }
+ $email = '<a href="';
+ if ($registry->hasMethod('mail/compose')) {
+ $email .= $registry->call(
+ 'mail/compose',
+ array(array('to' => $address['value'])));
+ } else {
+ $email .= 'mailto:' . htmlspecialchars($address['value']);
+ }
+ $email .= '">' . htmlspecialchars($address['value']) . '</a>';
+ if (isset($address['params']['PREF'])) {
+ array_unshift($emails, $email);
+ } else {
+ $emails[] = $email;
+ }
+ }
+
+ if (count($emails)) {
+ $html .= $this->_row(_("Email"), implode("\n", $emails), false);
+ }
+
+ $title = $vc->getAttributeValues('TITLE');
+ if (!is_a($title, 'PEAR_Error')) {
+ $html .= $this->_row(_("Title"), $title[0]);
+ }
+
+ $role = $vc->getAttributeValues('ROLE');
+ if (!is_a($role, 'PEAR_Error')) {
+ $html .= $this->_row(_("Role"), $role[0]);
+ }
+
+ $org = $vc->getAttributeValues('ORG');
+ if (!is_a($org, 'PEAR_Error')) {
+ $html .= $this->_row(_("Company"), $org[0]);
+ if (isset($org[1])) {
+ $html .= $this->_row(_("Department"), $org[1]);
+ }
+ }
+
+ $notes = $vc->getAttributeValues('NOTE');
+ if (!is_a($notes, 'PEAR_Error')) {
+ $html .= $this->_row(_("Notes"), $notes[0]);
+ }
+
+ $url = $vc->getAttributeValues('URL');
+ if (!is_a($url, 'PEAR_Error')) {
+ $html .= $this->_row(
+ _("URL"),
+ '<a href="' . htmlspecialchars($url[0])
+ . '" target="_blank">' . htmlspecialchars($url[0])
+ . '</a>',
+ false);
+ }
+ }
+
+ if ($registry->hasMethod('contacts/import') &&
+ $registry->hasMethod('contacts/sources')) {
+ $html .= '<tr><td colspan="2" class="smallheader"><form action="'
+ . Horde::selfUrl() . '" method="get" name="vcard_import">'
+ . Horde_Util::formInput();
+ foreach ($_GET as $key => $val) {
+ $html .= '<input type="hidden" name="' . htmlspecialchars($key)
+ . '" value="' . htmlspecialchars($val) . '" />';
+ }
+
+ $sources = $registry->call('contacts/sources', array(true));
+ if (count($sources) > 1) {
+ $html .=
+ '<input type="submit" class="button" name="import" value="'
+ . _("Add to address book:") . '" />'
+ . '<label for="add_source" class="hidden">'
+ . _("Address Book") . '</label>'
+ . '<select id="add_source" name="source">';
+ foreach ($sources as $key => $label) {
+ $selected = ($key == $prefs->getValue('add_source'))
+ ? ' selected="selected"' : '';
+ $html .= '<option value="' . htmlspecialchars($key) . '"'
+ . $selected . '>' . htmlspecialchars($label)
+ . '</option>';
+ }
+ } else {
+ reset($sources);
+ $html .=
+ '<input type="submit" class="button" name="import" value="'
+ . _("Add to my address book") . '" />'
+ . '<input type="hidden" name="source" value="'
+ . htmlspecialchars(key($sources)) . '" />';
+ }
+
+ $html .= '</form></td></tr><tr><td> </td></tr>';
+ }
+
+ $html .= '</table>';
+
+ Horde::startBuffer();
+ $notification->notify(array('listeners' => 'status'));
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => Horde::endBuffer() . $html,
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+
+ /**
+ * TODO
+ */
+ protected function _row($label, $value, $encode = true)
+ {
+ if ($encode) {
+ $label = htmlspecialchars($label);
+ $value = htmlspecialchars($value);
+ }
+ return '<tr><td class="item" valign="top">' . $label .
+ '</td><td class="item" valign="top">' . nl2br($value) .
+ "</td></tr>\n";
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Wordperfect class renders out WordPerfect documents
+ * in HTML format by using the libwpd package.
+ *
+ * libpwd website: http://libwpd.sourceforge.net/
+ *
+ * Copyright 2007-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Matt Selsky <selsky@columbia.edu>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Wordperfect extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => false,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ */
+ protected function _render()
+ {
+ /* Check to make sure the viewer program exists. */
+ if (!isset($this->_conf['location']) ||
+ !file_exists($this->_conf['location'])) {
+ return array();
+ }
+
+ $tmp_wpd = Horde::getTempFile('wpd');
+ $tmp_output = Horde::getTempFile('wpd');
+
+ file_put_contents($tmp_wpd, $this->_mimepart->getContents());
+
+ exec($this->_conf['location'] . " $tmp_wpd > $tmp_output");
+
+ if (file_exists($tmp_output)) {
+ $data = file_get_contents($tmp_output);
+ } else {
+ $data = _("Unable to translate this WordPerfect document");
+ }
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => $data,
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Zip class renders out the contents of ZIP files in
+ * HTML format.
+ *
+ * Copyright 2000-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @author Michael Cochrane <mike@graftonhall.co.nz>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Driver
+{
+ /**
+ * This driver's display capabilities.
+ *
+ * @var array
+ */
+ protected $_capability = array(
+ 'full' => true,
+ 'info' => true,
+ 'inline' => false,
+ 'raw' => false
+ );
+
+ /**
+ * Metadata for the current viewer/data.
+ *
+ * @var array
+ */
+ protected $_metadata = array(
+ 'compressed' => true,
+ 'embedded' => false,
+ 'forceinline' => false
+ );
+
+ /**
+ * A callback function to use in _toHTML().
+ *
+ * @var callback
+ */
+ protected $_callback = null;
+
+ /**
+ * Return the full rendered version of the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _render()
+ {
+ $ret = $this->_toHTML();
+ if (!empty($ret)) {
+ reset($ret);
+ $ret[key($ret)]['data'] = '<html><body>' . $ret[key($ret)]['data'] . '</body></html>';
+ }
+ return $ret;
+ }
+
+ /**
+ * Return the rendered information about the Horde_Mime_Part object.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _renderInfo()
+ {
+ return $this->_toHTML();
+ }
+
+ /**
+ * Converts the ZIP file to an HTML display.
+ *
+ * @return array See Horde_Mime_Viewer_Driver::render().
+ * @throws Horde_Exception
+ */
+ protected function _toHTML()
+ {
+ $contents = $this->_mimepart->getContents();
+
+ $zip = Horde_Compress::factory('zip');
+ $zipInfo = $zip->decompress($contents, array('action' => Horde_Compress_Zip::ZIP_LIST));
+
+ $fileCount = count($zipInfo);
+
+ /* Determine maximum file name length. */
+ $max_array = array();
+ foreach ($zipInfo as $val) {
+ $max_array[] = strlen($val['name']);
+ }
+ $maxlen = empty($max_array) ? 0 : max($max_array);
+
+ $name = $this->_mimepart->getName(true);
+ if (empty($name)) {
+ $name = _("unnamed");
+ }
+
+ $text = '<strong>' . htmlspecialchars(sprintf(_("Contents of \"%s\""), $name)) . ":</strong>\n" .
+ '<table><tr><td align="left"><span style="font-family:monospace">' .
+ Horde_Text_Filter::filter(
+ _("Archive Name") . ': ' . $name . "\n" .
+ _("Archive File Size") . ': ' . strlen($contents) .
+ " bytes\n" .
+ sprintf(ngettext("File Count: %d file", "File Count: %d files", $fileCount), $fileCount) .
+ "\n\n" .
+ Horde_String::pad(_("File Name"), $maxlen, ' ', STR_PAD_RIGHT) .
+ Horde_String::pad(_("Attributes"), 10, ' ', STR_PAD_LEFT) .
+ Horde_String::pad(_("Size"), 10, ' ', STR_PAD_LEFT) .
+ Horde_String::pad(_("Modified Date"), 19, ' ', STR_PAD_LEFT) .
+ Horde_String::pad(_("Method"), 10, ' ', STR_PAD_LEFT) .
+ Horde_String::pad(_("Ratio"), 10, ' ', STR_PAD_LEFT) .
+ "\n",
+ 'space2html',
+ array('charset' => $GLOBALS['registry']->getCharset(), 'encode' => true, 'encode_all' => true)
+ ) . str_repeat('-', 59 + $maxlen) . "\n";
+
+ foreach ($zipInfo as $key => $val) {
+ $ratio = (empty($val['size']))
+ ? 0
+ : 100 * ($val['csize'] / $val['size']);
+
+ $val['name'] = Horde_String::pad($val['name'], $maxlen, ' ', STR_PAD_RIGHT);
+ $val['attr'] = Horde_String::pad($val['attr'], 10, ' ', STR_PAD_LEFT);
+ $val['size'] = Horde_String::pad($val['size'], 10, ' ', STR_PAD_LEFT);
+ $val['date'] = Horde_String::pad(strftime("%d-%b-%Y %H:%M", $val['date']), 19, ' ', STR_PAD_LEFT);
+ $val['method'] = Horde_String::pad($val['method'], 10, ' ', STR_PAD_LEFT);
+ $val['ratio'] = Horde_String::pad(sprintf("%1.1f%%", $ratio), 10, ' ', STR_PAD_LEFT);
+
+ reset($val);
+ while (list($k, $v) = each($val)) {
+ $val[$k] = Horde_Text_Filter::filter($v, 'space2html', array('charset' => $GLOBALS['registry']->getCharset(), 'encode' => true, 'encode_all' => true));
+ }
+
+ if (!is_null($this->_callback)) {
+ $val = call_user_func($this->_callback, $key, $val);
+ }
+
+ $text .= $val['name'] . $val['attr'] . $val['size'] .
+ $val['date'] . $val['method'] . $val['ratio'] .
+ "\n";
+ }
+
+ return array(
+ $this->_mimepart->getMimeId() => array(
+ 'data' => nl2br($text . str_repeat('-', 59 + $maxlen) . "\n</span></td></tr></table>"),
+ 'status' => array(),
+ 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset()
+ )
+ );
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.4.9" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+http://pear.php.net/dtd/tasks-1.0.xsd
+http://pear.php.net/dtd/package-2.0
+http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Mime_Viewer</name>
+ <channel>pear.horde.org</channel>
+ <summary>Horde MIME Viewer Library</summary>
+ <description>Provides rendering drivers for MIME data.
+ </description>
+ <lead>
+ <name>Michael Slusarz</name>
+ <user>slusarz</user>
+ <email>slusarz@horde.org</email>
+ <active>yes</active>
+ </lead>
+ <date>2010-07-25</date>
+ <version>
+ <release>0.1.0</release>
+ <api>0.1.0</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
+ <notes>* Initial package.
+ </notes>
+ <contents>
+ <dir name="/">
+ <dir name="lib">
+ <dir name="Horde">
+ <dir name="Mime">
+ <dir name="Viewer">
+ <dir name="Ooo">
+ <file name="common.xsl" role="php" />
+ <file name="global_document.xsl" role="php" />
+ <file name="main_html.xsl" role="php" />
+ <file name="palm.xsl" role="php" />
+ <file name="style_header.xsl" role="php" />
+ <file name="style_inlined.xsl" role="php" />
+ <file name="style_mapping.xsl" role="php" />
+ <file name="table.xsl" role="php" />
+ <file name="table_cells.xsl" role="php" />
+ <file name="table_columns.xsl" role="php" />
+ <file name="table_rows.xsl" role="php" />
+ </dir> <!-- /lib/Horde/Mime/Viewer/Ooo -->
+ <file name="Audio.php" role="php" />
+ <file name="Css.php" role="php" />
+ <file name="Deb.php" role="php" />
+ <file name="Default.php" role="php" />
+ <file name="Driver.php" role="php" />
+ <file name="Enriched.php" role="php" />
+ <file name="Exception.php" role="php" />
+ <file name="Html.php" role="php" />
+ <file name="Images.php" role="php" />
+ <file name="Msexcel.php" role="php" />
+ <file name="Mspowerpoint.php" role="php" />
+ <file name="Msword.php" role="php" />
+ <file name="Ooo.php" role="php" />
+ <file name="Pdf.php" role="php" />
+ <file name="Php.php" role="php" />
+ <file name="Plain.php" role="php" />
+ <file name="Rar.php" role="php" />
+ <file name="Report.php" role="php" />
+ <file name="Rfc822.php" role="php" />
+ <file name="Richtext.php" role="php" />
+ <file name="Rpm.php" role="php" />
+ <file name="Rtf.php" role="php" />
+ <file name="Security.php" role="php" />
+ <file name="Simple.php" role="php" />
+ <file name="Smil.php" role="php" />
+ <file name="Source.php" role="php" />
+ <file name="Srchighlite.php" role="php" />
+ <file name="Tgz.php" role="php" />
+ <file name="Tnef.php" role="php" />
+ <file name="Vcard.php" role="php" />
+ <file name="Wordperfect.php" role="php" />
+ <file name="Zip.php" role="php" />
+ </dir> <!-- /lib/Horde/Mime/Viewer -->
+ <file name="Viewer.php" role="php" />
+ </dir> <!-- /lib/Horde/Mime -->
+ </dir> <!-- /lib/Horde -->
+ </dir> <!-- /lib -->
+ <dir name="test">
+ <dir name="Horde">
+ <dir name="Mime">
+ <dir name="Viewer">
+ <file name="url.phpt" role="test" />
+ <file name="viewer_php.phpt" role="test" />
+ </dir> <!-- /test/Horde/Mime/Viewer -->
+ </dir> <!-- /test/Horde/Mime -->
+ </dir> <!-- /test/Horde -->
+ </dir> <!-- /test -->
+ </dir> <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.2.0</min>
+ </php>
+ <pearinstaller>
+ <min>1.5.4</min>
+ </pearinstaller>
+ <package>
+ <name>Core</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
+ <name>Exception</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
+ <name>Mime</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
+ <name>Util</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <extension>
+ <name>gettext</name>
+ </extension>
+ </required>
+ <optional>
+ <package>
+ <name>Browser</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
+ <name>Compress</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
+ <name>iCalendar</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
+ <name>Text_Filter</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ </optional>
+ </dependencies>
+ <phprelease>
+ <filelist>
+ <install name="lib/Horde/Mime/Viewer/Ooo/common.xsl" as="Horde/Mime/Viewer/Ooo/common.xsl" />
+ <install name="lib/Horde/Mime/Viewer/Ooo/global_document.xsl" as="Horde/Mime/Viewer/Ooo/global_document.xsl" />
+ <install name="lib/Horde/Mime/Viewer/Ooo/main_html.xsl" as="Horde/Mime/Viewer/Ooo/main_html.xsl" />
+ <install name="lib/Horde/Mime/Viewer/Ooo/palm.xsl" as="Horde/Mime/Viewer/Ooo/palm.xsl" />
+ <install name="lib/Horde/Mime/Viewer/Ooo/style_header.xsl" as="Horde/Mime/Viewer/Ooo/style_header.xsl" />
+ <install name="lib/Horde/Mime/Viewer/Ooo/style_inlined.xsl" as="Horde/Mime/Viewer/Ooo/style_inlined.xsl" />
+ <install name="lib/Horde/Mime/Viewer/Ooo/style_mapping.xsl" as="Horde/Mime/Viewer/Ooo/style_mapping.xsl" />
+ <install name="lib/Horde/Mime/Viewer/Ooo/table.xsl" as="Horde/Mime/Viewer/Ooo/table.xsl" />
+ <install name="lib/Horde/Mime/Viewer/Ooo/table_cells.xsl" as="Horde/Mime/Viewer/Ooo/table_cells.xsl" />
+ <install name="lib/Horde/Mime/Viewer/Ooo/table_columns.xsl" as="Horde/Mime/Viewer/Ooo/table_columns.xsl" />
+ <install name="lib/Horde/Mime/Viewer/Ooo/table_rows.xsl" as="Horde/Mime/Viewer/Ooo/table_rows.xsl" />
+ <install name="lib/Horde/Mime/Viewer/Audio.php" as="Horde/Mime/Viewer/Audio.php" />
+ <install name="lib/Horde/Mime/Viewer/Css.php" as="Horde/Mime/Viewer/Css.php" />
+ <install name="lib/Horde/Mime/Viewer/Deb.php" as="Horde/Mime/Viewer/Deb.php" />
+ <install name="lib/Horde/Mime/Viewer/Default.php" as="Horde/Mime/Viewer/Default.php" />
+ <install name="lib/Horde/Mime/Viewer/Driver.php" as="Horde/Mime/Viewer/Driver.php" />
+ <install name="lib/Horde/Mime/Viewer/Enriched.php" as="Horde/Mime/Viewer/Enriched.php" />
+ <install name="lib/Horde/Mime/Viewer/Exception.php" as="Horde/Mime/Viewer/Exception.php" />
+ <install name="lib/Horde/Mime/Viewer/Html.php" as="Horde/Mime/Viewer/Html.php" />
+ <install name="lib/Horde/Mime/Viewer/Images.php" as="Horde/Mime/Viewer/Images.php" />
+ <install name="lib/Horde/Mime/Viewer/Msexcel.php" as="Horde/Mime/Viewer/Msexcel.php" />
+ <install name="lib/Horde/Mime/Viewer/Mspowerpoint.php" as="Horde/Mime/Viewer/Mspowerpoint.php" />
+ <install name="lib/Horde/Mime/Viewer/Msword.php" as="Horde/Mime/Viewer/Msword.php" />
+ <install name="lib/Horde/Mime/Viewer/Ooo.php" as="Horde/Mime/Viewer/Ooo.php" />
+ <install name="lib/Horde/Mime/Viewer/Pdf.php" as="Horde/Mime/Viewer/Pdf.php" />
+ <install name="lib/Horde/Mime/Viewer/Php.php" as="Horde/Mime/Viewer/Php.php" />
+ <install name="lib/Horde/Mime/Viewer/Plain.php" as="Horde/Mime/Viewer/Plain.php" />
+ <install name="lib/Horde/Mime/Viewer/Rar.php" as="Horde/Mime/Viewer/Rar.php" />
+ <install name="lib/Horde/Mime/Viewer/Report.php" as="Horde/Mime/Viewer/Report.php" />
+ <install name="lib/Horde/Mime/Viewer/Rfc822.php" as="Horde/Mime/Viewer/Rfc822.php" />
+ <install name="lib/Horde/Mime/Viewer/Richtext.php" as="Horde/Mime/Viewer/Richtext.php" />
+ <install name="lib/Horde/Mime/Viewer/Rpm.php" as="Horde/Mime/Viewer/Rpm.php" />
+ <install name="lib/Horde/Mime/Viewer/Rtf.php" as="Horde/Mime/Viewer/Rtf.php" />
+ <install name="lib/Horde/Mime/Viewer/Security.php" as="Horde/Mime/Viewer/Security.php" />
+ <install name="lib/Horde/Mime/Viewer/Simple.php" as="Horde/Mime/Viewer/Simple.php" />
+ <install name="lib/Horde/Mime/Viewer/Smil.php" as="Horde/Mime/Viewer/Smil.php" />
+ <install name="lib/Horde/Mime/Viewer/Source.php" as="Horde/Mime/Viewer/Source.php" />
+ <install name="lib/Horde/Mime/Viewer/Srchighlite.php" as="Horde/Mime/Viewer/Srchighlite.php" />
+ <install name="lib/Horde/Mime/Viewer/Tgz.php" as="Horde/Mime/Viewer/Tgz.php" />
+ <install name="lib/Horde/Mime/Viewer/Tnef.php" as="Horde/Mime/Viewer/Tnef.php" />
+ <install name="lib/Horde/Mime/Viewer/Vcard.php" as="Horde/Mime/Viewer/Vcard.php" />
+ <install name="lib/Horde/Mime/Viewer/Wordperfect.php" as="Horde/Mime/Viewer/Wordperfect.php" />
+ <install name="lib/Horde/Mime/Viewer/Zip.php" as="Horde/Mime/Viewer/Zip.php" />
+ <install name="lib/Horde/Mime/Viewer.php" as="Horde/Mime/Viewer.php" />
+ </filelist>
+ </phprelease>
+</package>
--- /dev/null
+--TEST--
+Horde_Mime_Viewer_html: URL dereferer tests
+--SKIPIF--
+skip: Horde_Mime_Viewer has too many dependencies.
+--FILE--
+<?php
+
+$dirname = dirname(__FILE__);
+require_once $dirname . '/../../../lib/Horde/Mime/Part.php';
+require_once $dirname . '/../../../lib/Horde/Mime/Viewer.php';
+require_once 'Horde.php';
+
+class Registry {
+ function get($param, $app = null)
+ {
+ if ($param == 'webroot' || $app == 'horde') {
+ return '/horde';
+ }
+ die("Can't emulate Registry. \$param: $param, \$app: $app");
+ }
+}
+
+class Browser {
+ function isBrowser($agent)
+ {
+ return $agent == 'msie';
+ }
+}
+
+$conf = array(
+ 'server' => array(
+ 'name' => 'www.example.com',
+ 'port' => 80
+ ),
+ 'use_ssl' => 0
+);
+$registry = new Registry();
+$browser = new Browser();
+
+$tests = array(
+ '<A HREF=http://66.102.7.147/>link</A>',
+ '<A HREF=http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D>link</A>',
+ '<A HREF=ht://www.google.com/>link</A>',
+ '<A HREF=http://google.com/>link</A>',
+ '<A HREF=http://www.google.com./>link</A>',
+ '<A HREF="javascript:document.location=\'http://www.google.com/\'">link</A>',
+ '<A HREF=http://www.gohttp://www.google.com/ogle.com/>link</A>'
+);
+
+foreach ($tests as $val) {
+ $part = new Horde_Mime_Part();
+ $part->setType('text/html');
+ $part->setContents($val);
+ $viewer = Horde_Mime_Viewer::factory($part, 'text/html');
+ echo $viewer->render();
+}
+
+?>
+--EXPECT--
+<A href="http://www.example.com/horde/services/go.php?url=http%3A%2F%2F66.102.7.147%2F">link</A>
+<A href="http://www.example.com/horde/services/go.php?url=http%3A%2F%2F%2577%2577%2577%252E%2567%256F%256F%2567%256C%2565%252E%2563%256F%256D">link</A>
+<A href="http://www.example.com/horde/services/go.php?url=ht%3A%2F%2Fwww.google.com%2F">link</A>
+<A href="http://www.example.com/horde/services/go.php?url=http%3A%2F%2Fgoogle.com%2F">link</A>
+<A href="http://www.example.com/horde/services/go.php?url=http%3A%2F%2Fwww.google.com.%2F">link</A>
+<A href="http://www.example.com/horde/services/go.php?url=XSSCleaneddocument.location%3D%27http%3A%2F%2Fwww.google.com%2F%27">link</A>
+<A href="http://www.example.com/horde/services/go.php?url=http%3A%2F%2Fwww.gohttp%3A%2F%2Fwww.google.com%2Fogle.com%2F">link</A>
--- /dev/null
+--TEST--
+PHP source viewer
+--SKIPIF--
+skip: Horde_Mime_Viewer has too many dependencies.
+--FILE--
+<?php
+
+require_once dirname(__FILE__) . '/../../../lib/Horde/Mime/Part.php';
+require_once dirname(__FILE__) . '/../../../lib/Horde/Mime/Viewer.php';
+
+ini_set('highlight.comment', 'comment');
+ini_set('highlight.default', 'default');
+ini_set('highlight.keyword', 'keyword');
+ini_set('highlight.string', 'string');
+ini_set('highlight.html', 'html');
+
+$part = new Horde_Mime_Part();
+$part->setType('application/x-php');
+$part->setContents(str_replace('<?php ', '', highlight_string('<?php highlight_file(__FILE__);', true)));
+
+$viewer = Horde_Mime_Viewer::factory($part);
+echo $viewer->render();
+?>
+--EXPECT--
+<ol class="code-listing striped">
+<li id="l1"><span class="default">highlight_file</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">);</span></li>
+</ol>