1<?php
2
3require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
4
5/**
6 * ODTElementSpan:
7 * Class for handling the span element.
8 *
9 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
10 * @author  LarsDW223
11 */
12class ODTElementSpan extends ODTStateElement
13{
14    /**
15     * Constructor.
16     */
17    public function __construct($style_name=NULL) {
18        parent::__construct();
19        $this->setClass ('span');
20        if ($style_name != NULL) {
21            $this->setStyleName ($style_name);
22        }
23    }
24
25    /**
26     * Return the elements name.
27     *
28     * @return string The ODT XML element name.
29     */
30    public function getElementName () {
31        return ('text:span');
32    }
33
34    /**
35     * Return string with encoded opening tag.
36     *
37     * @return string The ODT XML code to open this element.
38     */
39    public function getOpeningTag () {
40        return '<text:span text:style-name="'.$this->getStyleName().'">';
41    }
42
43    /**
44     * Return string with encoded closing tag.
45     *
46     * @return string The ODT XML code to close this element.
47     */
48    public function getClosingTag () {
49        return '</text:span>';
50    }
51
52    /**
53     * Are we in a paragraph or not?
54     * As a span we ask our parent.
55     *
56     * @return boolean
57     */
58    public function getInParagraph() {
59        $parent = $this->getParent();
60        if ($parent != NULL) {
61            return $parent->getInParagraph();
62        }
63        return NULL;
64    }
65
66    /**
67     * Determine and set the parent for this element.
68     * As a span the previous element is our parent.
69     *
70     * @param ODTStateElement $previous
71     */
72    public function determineParent(ODTStateElement $previous) {
73        $this->setParent($previous);
74    }
75}
76