add contents

This commit is contained in:
Trevor Batley
2025-10-09 15:04:29 +11:00
parent 170362eec1
commit bce7dd054a
2537 changed files with 301282 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* Interface iContainerAccess
*
* To prevent clashes with other interfaces function names all functions
* are prefixed with iCA_.
*
* @package ODT\iContainerAccess
*/
interface iContainerAccess
{
public function isNested ();
public function addNestedContainer (iContainerAccess $nested);
public function getNestedContainers ();
public function determinePositionInContainer (array &$data, ODTStateElement $current);
public function getMaxWidthOfNestedContainer (ODTInternalParams $params, array $data);
}
/**
* ODTContainerElement:
* Class for extra code to support container elements (frame and table).
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTContainerElement
{
// Container specific state data
protected $owner = NULL;
protected $is_nested = false;
protected $nestedContainers = array();
/**
* Constructor.
*/
public function __construct(ODTStateElement $owner) {
$this->owner = $owner;
}
/**
* Determine and set the parent for this element.
* The parent is the previous element.
*
* If the container is nested in another table or frame,
* then the surrounding table or frame is the parent!
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
$container = $previous;
while ($container != NULL) {
if ($container->getClass() == 'table-cell') {
$cell = $container;
}
if ($container->getClass() == 'table') {
break;
}
if ($container->getClass() == 'frame') {
break;
}
$container = $container->getParent();
}
if ($container == NULL) {
$this->owner->setParent($previous);
} else {
$this->owner->setParent($container);
$container->addNestedContainer ($this->owner);
$this->is_nested = true;
}
}
/**
* Is this container nested in another container
* (inserted into another table or frame)?
*
* @return boolean
*/
public function isNested () {
return $this->is_nested;
}
public function addNestedContainer (iContainerAccess $nested) {
$this->nestedContainers [] = $nested;
}
public function getNestedContainers () {
return $this->nestedContainers;
}
}

View File

@@ -0,0 +1,299 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementFrame:
* Class for handling the frame element.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementFrame extends ODTStateElement implements iContainerAccess
{
protected $container = NULL;
protected $containerPos = NULL;
protected $attributes = NULL;
protected $own_max_width = NULL;
protected $nameAttr = NULL;
protected $name = NULL;
protected $written = false;
/**
* Constructor.
*/
public function __construct($style_name=NULL) {
parent::__construct();
$this->setClass ('frame');
if ($style_name != NULL) {
$this->setStyleName ($style_name);
}
$this->container = new ODTContainerElement($this);
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('draw:frame');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag (ODTInternalParams $params=NULL) {
// Convert width to points
$width = $this->getWidth();
if ($width !== NULL) {
$width = $params->units->toPoints($width);
$this->setWidth($width);
}
$encoded = '<draw:frame draw:style-name="'.$this->getStyleName().'" ';
$encoded .= $this->getAttributes().'>';
$this->written = true;
return $encoded;
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
return '</draw:frame>';
}
/**
* Are we in a paragraph or not?
* As a frame we are not.
*
* @return boolean
*/
public function getInParagraph() {
return false;
}
/**
* Determine and set the parent for this element.
* As a frame the previous element is our parent.
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
$this->container->determineParent($previous);
if ($this->isNested ()) {
$this->containerPos = array();
$this->getParent()->determinePositionInContainer($this->containerPos, $previous);
}
//$this->setParent($previous);
}
/**
* Set frame attributes
*
* @param array $value
*/
public function setAttributes($value) {
// Delete linebreaks and multiple whitespace
$this->attributes = preg_replace( "/\r|\n/", "", $value);
$this->attributes = preg_replace( "/\s+/", " ", $this->attributes);
// Save name for later width rewriting
$this->nameAttr = $this->getNameAttribute();
$this->name = $this->getName();
}
/**
* Get frame attributes
*
* @return array
*/
public function getAttributes() {
return $this->attributes;
}
/**
* Is this frame a nested frame (inserted into another table/frame)?
*
* @return boolean
*/
public function isNested () {
return $this->container->isNested();
}
public function addNestedContainer (iContainerAccess $nested) {
$this->container->addNestedContainer ($nested);
}
public function getNestedContainers () {
return $this->container->getNestedContainers ();
}
public function determinePositionInContainer (array &$data, ODTStateElement $current) {
// Position in frame doesn't mater for width calculation
// So this is a dummy for now
$data ['frame'] = true;
}
public function getMaxWidthOfNestedContainer (ODTInternalParams $params, array $data) {
if ($this->own_max_width === NULL) {
// We do not know our own width yet. Calculate it first.
$this->own_max_width = $this->getMaxWidth($params);
// Re-Write our width if frame already has been written to the document
if ($this->written) {
if (preg_match('/<draw:frame[^<]*'.$this->nameAttr.'[^>]*>/', $params->content, $matches) === 1) {
$frameTag = $matches [0];
$frameTag = preg_replace('/svg:width="[^"]*"/', 'svg:width="'.$this->own_max_width.'"', $frameTag);
// Replace old frame tag in document in
$params->content = str_replace ($matches [0], $frameTag, $params->content);
}
}
}
// Convert to points
if ($this->own_max_width !== NULL) {
$width = $params->units->getDigits ($params->units->toPoints($this->own_max_width));
}
return $width.'pt';
}
public function getMaxWidth (ODTInternalParams $params) {
if ($this->own_max_width !== NULL) {
return $this->own_max_width;
}
$frameStyle = $this->getStyle();
// Get frame left margin
$leftMargin = $frameStyle->getProperty('margin-left');
if ($leftMargin == NULL) {
$leftMarginPt = 0;
} else {
$leftMarginPt = $params->units->getDigits ($params->units->toPoints($leftMargin));
}
// Get frame right margin
$rightMargin = $frameStyle->getProperty('margin-right');
if ($rightMargin == NULL) {
$rightMarginPt = 0;
} else {
$rightMarginPt = $params->units->getDigits ($params->units->toPoints($rightMargin));
}
// Get available max width
if (!$this->isNested ()) {
// Get max page width in points.
$maxWidth = $params->document->getAbsWidthMindMargins ();
$maxWidthPt = $params->units->getDigits ($params->units->toPoints($maxWidth.'cm'));
} else {
// If this frame is nested in another container we have to ask it's parent
// for the allowed max width
$maxWidth = $this->getParent()->getMaxWidthOfNestedContainer($params, $this->containerPos);
$maxWidthPt = $params->units->getDigits ($params->units->toPoints($maxWidth));
}
// Get frame width
$width = $this->getWidth();
if ($width !== NULL) {
if ($width [strlen($width)-1] != '%') {
$widthPt = $params->units->getDigits ($params->units->toPoints($width));
} else {
$percentage = trim ($width, '%');
$widthPt = ($percentage * $maxWidthPt)/100;
}
}
// Calculate final width.
// If no frame width is set or the frame width is greater than
// the calculated max width then use the max width.
$maxWidthPt = $maxWidthPt - $leftMarginPt - $rightMarginPt;
if ($width == NULL || $widthPt > $maxWidthPt) {
$width = $maxWidthPt - $leftMarginPt - $rightMarginPt;
} else {
$width = $widthPt;
}
$width = $width.'pt';
return $width;
}
public function getWidth() {
if ($this->attributes !== NULL) {
if ( preg_match('/svg:width="[^"]+"/', $this->attributes, $matches) === 1 ) {
$width = substr ($matches [0], 11);
$width = trim ($width, '"');
return $width;
}
}
return NULL;
}
public function setWidth($width) {
if ($this->attributes !== NULL) {
if ( preg_match('/svg:width="[^"]+"/', $this->attributes, $matches) === 1 ) {
$widthAttr = 'svg:width="'.$width.'"';
$this->attributes = str_replace($matches [0], $widthAttr, $this->attributes);
return;
}
}
$this->attributes .= ' svg:width="'.$width.'"';
}
public function getNameAttribute() {
if ($this->attributes !== NULL) {
if ( preg_match('/draw:name="[^"]+"/', $this->attributes, $matches) === 1 ) {
return $matches [0];
}
}
return NULL;
}
public function getName() {
if ($this->attributes !== NULL) {
if ( preg_match('/draw:name="[^"]+"/', $this->attributes, $matches) === 1 ) {
$name = substr ($matches [0], 10);
$name = trim ($name, '"');
return $name;
}
}
return NULL;
}
/**
* This function adjust the width of the frame.
* There is not much to do except conversion of relative to absolute values
* and calling the method for all nested elements.
* (table has got more work to do, see ODTElementTable::adjustWidth)
*
* @param ODTInternalParams $params Common ODT params
* @param boolean $allowNested Allow to process call if this frame is nested
*/
public function adjustWidth (ODTInternalParams $params, $allowNested=false) {
if ($this->isNested () && !$allowNested) {
// Do not do anything if this is a nested table.
// Only if the function is called for the parent/root table
// then the width of the nested tables will be calculated.
return;
}
$matches = array ();
$max_width = $this->getMaxWidth($params);
//FIXME: convert % to points
// Now adjust all nested containers too
$nested = $this->getNestedContainers ();
foreach ($nested as $container) {
$container->adjustWidth ($params, true);
}
}
}

View File

@@ -0,0 +1,153 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementList:
* Class for handling the list element.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementList extends ODTStateElement
{
// List state data
protected $continue_numbering;
protected $in_list = false;
protected $list_first_paragraph = true;
protected $list_paragraph_pos = -1;
/**
* Constructor.
*/
public function __construct($style_name=NULL, $continue=false) {
parent::__construct();
$this->setClass ('list');
if ($style_name != NULL) {
$this->setStyleName ($style_name);
}
$this->setContinueNumbering ($continue);
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('text:list');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
$encoded = '<text:list text:style-name="'.$this->getStyleName().'"';
if ($this->getContinueNumbering()) {
$encoded .= ' text:continue-numbering="true" ';
} else {
if ($this->in_list === false) {
$encoded .= ' text:continue-numbering="false" ';
}
}
$encoded .= '>';
return $encoded;
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
return '</text:list>';
}
/**
* Are we in a paragraph or not?
* As a list we are not.
*
* @return boolean
*/
public function getInParagraph() {
return false;
}
/**
* Determine and set the parent for this element.
* As a list the previous element is our parent.
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
$this->setParent($previous);
// Check if this is a nested list
while ($previous != NULL) {
if ($previous->getClass() == 'list') {
break;
}
$previous = $previous->getParent();
}
if ($previous != NULL) {
// Yes, nested list.
$this->in_list = true;
}
}
/**
* Set continue numbering to $value
*
* @param bool $value
*/
public function setContinueNumbering($value) {
$this->continue_numbering = $value;
}
/**
* Get continue numbering to $value
*
* @return bool
*/
public function getContinueNumbering() {
return $this->continue_numbering;
}
/**
* Set flag if the next paragraph will be the first in the list
*
* @param boolean $value
*/
public function setListFirstParagraph($value) {
$this->list_first_paragraph = $value;
}
/**
* Get flag if the next paragraph will be the first in the list
*
* @return boolean
*/
public function getListFirstParagraph() {
return $this->list_first_paragraph;
}
/**
* Set position of last opened paragraph in the list
*
* @param integer $value
*/
public function setListLastParagraphPosition($value) {
$this->list_paragraph_pos = $value;
}
/**
* Get position of last opened paragraph in the list
*
* @return integer
*/
public function getListLastParagraphPosition() {
return $this->list_paragraph_pos;
}
}

View File

@@ -0,0 +1,106 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementListHeader:
* Class for handling the list header element.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementListHeader extends ODTStateElement
{
// List item state data
protected $in_list_item = false;
protected $list_item_level = 0;
/**
* Constructor.
*/
public function __construct($level=0) {
parent::__construct();
$this->setClass ('list-item');
$this->setListItemLevel ($level);
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('text:list-header');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
return '<text:list-header>';
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
return '</text:list-header>';
}
/**
* Are we in a paragraph or not?
* As a list item we are not.
*
* @return boolean
*/
public function getInParagraph() {
return false;
}
/**
* Determine and set the parent for this element.
* As a list item the list element is our parent.
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
while ($previous != NULL) {
if ($previous->getClass() == 'list') {
break;
}
$previous = $previous->getParent();
}
$this->setParent($previous);
}
/**
* Set the level for an list item
*
* @param integer $value
*/
public function setListItemLevel($value) {
$this->list_item_level = $value;
}
/**
* Get level of a list item
*
* @return integer
*/
public function getListItemLevel() {
return $this->list_item_level;
}
/**
* Return the list to which this list item belongs.
*
* @return ODTStateElement
*/
public function getList () {
return $this->getParent();
}
}

View File

@@ -0,0 +1,106 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementListItem:
* Class for handling the list item element.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementListItem extends ODTStateElement
{
// List item state data
protected $in_list_item = false;
protected $list_item_level = 0;
/**
* Constructor.
*/
public function __construct($level=0) {
parent::__construct();
$this->setClass ('list-item');
$this->setListItemLevel ($level);
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('text:list-item');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
return '<text:list-item>';
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
return '</text:list-item>';
}
/**
* Are we in a paragraph or not?
* As a list item we are not.
*
* @return boolean
*/
public function getInParagraph() {
return false;
}
/**
* Determine and set the parent for this element.
* As a list item the list element is our parent.
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
while ($previous != NULL) {
if ($previous->getClass() == 'list') {
break;
}
$previous = $previous->getParent();
}
$this->setParent($previous);
}
/**
* Set the level for an list item
*
* @param integer $value
*/
public function setListItemLevel($value) {
$this->list_item_level = $value;
}
/**
* Get level of a list item
*
* @return integer
*/
public function getListItemLevel() {
return $this->list_item_level;
}
/**
* Return the list to which this list item belongs.
*
* @return ODTStateElement
*/
public function getList () {
return $this->getParent();
}
}

View File

@@ -0,0 +1,81 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementNote:
* Class for handling the text note element (e.g. for footnotes).
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementNote extends ODTStateElement
{
protected $value_type = 'string';
/**
* Constructor.
*/
public function __construct() {
parent::__construct();
$this->setClass ('text-note');
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('text:note');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
// Intentionally return an empty string!
return '';
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
// Intentionally return an empty string!
return '';
}
/**
* Are we in a paragraph or not?
* As a text note we are not.
*
* @return boolean
*/
public function getInParagraph() {
return false;
}
/**
* Determine and set the parent for this element.
* As a table cell our parent is the table element.
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
$this->setParent($previous);
}
/**
* Return the table to which this column belongs.
*
* @return ODTStateElement
*/
public function getTable () {
return $this->getParent();
}
}

View File

@@ -0,0 +1,71 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementParagraph:
* Class for handling the paragraph element.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementParagraph extends ODTStateElement
{
/**
* Constructor.
*/
public function __construct($style_name=NULL) {
parent::__construct();
$this->setClass ('paragraph');
if ($style_name != NULL) {
$this->setStyleName ($style_name);
}
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('text:p');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
return '<text:p text:style-name="'.$this->getStyleName().'">';
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
return '</text:p>';
}
/**
* Are we in a paragraph or not?
* As a paragraph we are of course.
*
* @return boolean
*/
public function getInParagraph() {
return true;
}
/**
* Determine and set the parent for this element.
* As a paragraph the previous element is our parent.
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
$this->setParent($previous);
}
}

View File

@@ -0,0 +1,75 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementSpan:
* Class for handling the span element.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementSpan extends ODTStateElement
{
/**
* Constructor.
*/
public function __construct($style_name=NULL) {
parent::__construct();
$this->setClass ('span');
if ($style_name != NULL) {
$this->setStyleName ($style_name);
}
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('text:span');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
return '<text:span text:style-name="'.$this->getStyleName().'">';
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
return '</text:span>';
}
/**
* Are we in a paragraph or not?
* As a span we ask our parent.
*
* @return boolean
*/
public function getInParagraph() {
$parent = $this->getParent();
if ($parent != NULL) {
return $parent->getInParagraph();
}
return NULL;
}
/**
* Determine and set the parent for this element.
* As a span the previous element is our parent.
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
$this->setParent($previous);
}
}

View File

@@ -0,0 +1,541 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTContainerElement.php';
/**
* ODTElementTable:
* Class for handling the table element.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementTable extends ODTStateElement implements iContainerAccess
{
// Table specific state data
protected $container = NULL;
protected $containerPos = NULL;
protected $table_column_styles = array ();
protected $table_style = NULL;
protected $table_autocols = false;
protected $table_maxcols = 0;
protected $table_curr_column = 0;
protected $table_row_count = 0;
protected $own_max_width = NULL;
// Flag indicating that a table was created inside of a list
protected $list_interrupted = false;
/**
* Constructor.
* ($numrows is currently unused)
*/
public function __construct($style_name=NULL, $maxcols = 0, $numrows = 0) {
parent::__construct();
$this->setClass ('table');
if ($style_name != NULL) {
$this->setStyleName ($style_name);
}
$this->setTableMaxColumns($maxcols);
if ($maxcols == 0) {
$this->setTableAutoColumns(true);
}
$this->container = new ODTContainerElement($this);
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('table:table');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
$style_name = $this->getStyleName();
if ($style_name == NULL) {
$encoded = '<table:table>';
} else {
$encoded .= '<table:table table:style-name="'.$style_name.'">';
}
$maxcols = $this->getTableMaxColumns();
$count = $this->getCount();
if ($maxcols == 0) {
// Try to automatically detect the number of columns.
$this->setTableAutoColumns(true);
} else {
$this->setTableAutoColumns(false);
}
// Add column definitions placeholder.
// This will be replaced on tabelClose()/getClosingTag()
$encoded .= '<ColumnsPlaceholder'.$count.'>';
// We start with the first column
$this->setTableCurrentColumn(0);
return $encoded;
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag (&$content = NULL) {
// Generate table column definitions and replace the placeholder with it
$count = $this->getCount();
$max = $this->getTableMaxColumns();
if ($max > 0 && $content != NULL) {
$column_defs = '';
for ($index = 0 ; $index < $max ; $index++) {
$styleName = $this->getTableColumnStyleName($index);
if (!empty($styleName)) {
$column_defs .= '<table:table-column table:style-name="'.$styleName.'"/>';
} else {
$column_defs .= '<table:table-column/>';
}
}
$content =
str_replace ('<ColumnsPlaceholder'.$count.'>', $column_defs, $content);
$content =
str_replace ('<MaxColsPlaceholder'.$count.'>', $max, $content);
}
return '</table:table>';
}
/**
* Are we in a paragraph or not?
* As a table we are not.
*
* @return boolean
*/
public function getInParagraph() {
return false;
}
/**
* Determine and set the parent for this element.
* As a table the previous element is our parent.
*
* If the table is nested in another table, then the surrounding
* table is the parent!
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
$this->container->determineParent($previous);
if ($this->isNested ()) {
$this->containerPos = array();
$this->getParent()->determinePositionInContainer($this->containerPos, $previous);
}
}
/**
* Set table column styles
*
* @param array $value
*/
public function setTableColumnStyles($value) {
$this->table_column_styles = $value;
}
/**
* Set table column style for $column
*
* @param array $value
*/
public function setTableColumnStyleName($column, $style_name) {
$this->table_column_styles [$column] = $style_name;
}
/**
* Get table column styles
*
* @return array
*/
public function getTableColumnStyles() {
return $this->table_column_styles;
}
/**
* Set table column style for $column
*
* @param array $value
*/
public function getTableColumnStyleName($column) {
return $this->table_column_styles [$column];
}
/**
* Set flag if table columns shall be generated automatically.
* (automatically detect the number of columns)
*
* @param boolean $value
*/
public function setTableAutoColumns($value) {
$this->table_autocols = $value;
}
/**
* Get flag if table columns shall be generated automatically.
* (automatically detect the number of columns)
*
* @return boolean
*/
public function getTableAutoColumns() {
return $this->table_autocols;
}
/**
* Set maximal number of columns.
*
* @param integer $value
*/
public function setTableMaxColumns($value) {
$this->table_maxcols = $value;
}
/**
* Get maximal number of columns.
*
* @return integer
*/
public function getTableMaxColumns() {
return $this->table_maxcols;
}
/**
* Set current column.
*
* @param integer $value
*/
public function setTableCurrentColumn($value) {
$this->table_curr_column = $value;
}
/**
* Get current column.
*
* @return integer
*/
public function getTableCurrentColumn() {
return $this->table_curr_column;
}
/**
* Get the predefined style name for the current
* table column.
*
* @return string
*/
public function getCurrentTableColumnStyleName() {
$table_column_styles = $this->getTableColumnStyles();
$curr_column = $this->getTableCurrentColumn();
return $table_column_styles [$curr_column];
}
/**
* Set flag if current list is interrupted (by a table) or not.
*
* @param boolean $value
*/
public function setListInterrupted($value) {
$this->list_interrupted = $value;
}
/**
* Get flag if current list is interrupted (by a table) or not.
*
* @return boolean
*/
public function getListInterrupted() {
return $this->list_interrupted;
}
/**
* Increae the number of rows
*
* @param boolean $value
*/
public function increaseRowCount() {
$this->table_row_count++;
}
public function getRowCount() {
return $this->table_row_count;
}
/**
* Is this table a nested table (inserted into another table)?
*
* @return boolean
*/
public function isNested () {
return $this->container->isNested();
}
public function addNestedContainer (iContainerAccess $nested) {
$this->container->addNestedContainer ($nested);
}
public function getNestedContainers () {
return $this->container->getNestedContainers ();
}
public function determinePositionInContainer (array &$data, ODTStateElement $current) {
$data ['column'] = $this->getTableCurrentColumn();
$cell = NULL;
while ($current != NULL) {
if ($current->getClass() == 'table-cell') {
$cell = $current;
break;
}
if ($current->getClass() == 'table') {
break;
}
$current = $current->getParent();
}
if ($cell !== NULL) {
$data ['cell'] = $cell;
}
}
public function getMaxWidthOfNestedContainer (ODTInternalParams $params, array $data) {
if ($this->own_max_width === NULL) {
// We do not know our own width yet. Calculate it first.
$this->own_max_width = $this->getMaxWidth($params);
}
$column = $data ['column'];
$cell = $data ['cell'];
$cell_style = $cell->getStyle();
$padding = 0;
if ($cell_style->getProperty('padding-left') != NULL
||
$cell_style->getProperty('padding-right') != NULL) {
$value = $cell_style->getProperty('padding-left');
$value = $params->document->toPoints($value, 'y');
$padding += $value;
$value = $cell_style->getProperty('padding-right');
$value = $params->document->toPoints($value, 'y');
$padding += $value;
} else if ($cell_style->getProperty('padding') != NULL) {
$value = $cell_style->getProperty('padding');
$value = $params->document->toPoints($value, 'y');
$padding += 2 * $value;
}
$table_column_styles = $this->getTableColumnStyles();
$style_name = $table_column_styles [$column-1];
$style_obj = $params->document->getStyle($style_name);
if ($style_obj !== NULL) {
$width = $style_obj->getProperty('column-width');
$width = trim ($width, 'pt');
$width -= $padding;
}
// Compare with total table width
if ($this->own_max_width !== NULL) {
$table_width = $params->units->getDigits ($params->units->toPoints($this->own_max_width));
if ($table_width < $width) {
$width = $table_width;
}
}
return $width.'pt';
}
public function getMaxWidth (ODTInternalParams $params) {
$tableStyle = $this->getStyle();
if (!$this->isNested ()) {
// Get max page width in points.
$maxPageWidth = $params->document->getAbsWidthMindMargins ();
$maxPageWidthPt = $params->units->getDigits ($params->units->toPoints($maxPageWidth.'cm'));
// Get table left margin
$leftMargin = $tableStyle->getProperty('margin-left');
if ($leftMargin === NULL) {
$leftMarginPt = 0;
} else {
$leftMarginPt = $params->units->getDigits ($params->units->toPoints($leftMargin));
}
// Get table right margin
$rightMargin = $tableStyle->getProperty('margin-right');
if ($rightMargin === NULL) {
$rightMarginPt = 0;
} else {
$rightMarginPt = $params->units->getDigits ($params->units->toPoints($rightMargin));
}
// Get table width
$width = $tableStyle->getProperty('width');
if ($width !== NULL) {
$widthPt = $params->units->getDigits ($params->units->toPoints($width));
}
if ($width === NULL) {
$width = $maxPageWidthPt - $leftMarginPt - $rightMarginPt;
} else {
$width = $widthPt;
}
$width = $width.'pt';
} else {
// If this table is nested in another container we have to ask it's parent
// for the allowed max width
$width = $this->getParent()->getMaxWidthOfNestedContainer($params, $this->containerPos);
}
return $width;
}
/**
* This function replaces the width of $table with the
* value of all column width added together. If a column has
* no width set then the function will abort and change nothing.
*
* @param ODTDocument $doc The current document
* @param ODTElementTable $table The table to be adjusted
*/
public function adjustWidth (ODTInternalParams $params, $allowNested=false) {
if ($this->isNested () && !$allowNested) {
// Do not do anything if this is a nested table.
// Only if the function is called for the parent/root table
// then the width of the nested tables will be calculated.
return;
}
$matches = array ();
$table_style_name = $this->getStyleName();
if (empty($table_style_name)) {
return;
}
$max_width = $this->getMaxWidth($params);
$width = $this->adjustWidthInternal ($params, $max_width);
$style_obj = $params->document->getStyle($table_style_name);
if ($style_obj != NULL) {
$style_obj->setProperty('width', $width.'pt');
if (!$this->isNested ()) {
// Calculate rel width in relation to maximum page width
$maxPageWidth = $params->document->getAbsWidthMindMargins ();
$maxPageWidth = $params->units->getDigits ($params->units->toPoints($maxPageWidth.'cm'));
if ($maxPageWidth != 0) {
$rel_width = round(($width * 100)/$maxPageWidth);
}
} else {
// Calculate rel width in relation to maximum table width
if ($max_width != 0) {
$rel_width = round(($width * 100)/$max_width);
}
}
$style_obj->setProperty('rel-width', $rel_width.'%');
}
// Now adjust all nested containers too
$nested = $this->getNestedContainers ();
foreach ($nested as $container) {
$container->adjustWidth ($params, true);
}
}
public function adjustWidthInternal (ODTInternalParams $params, $maxWidth) {
$empty = array();
$relative = array();
$anyWidthFound = false;
$onlyAbsWidthFound = true;
$tableStyle = $this->getStyle();
// First step:
// - convert all absolute widths to points
// - build the sum of all absolute column width values (if any)
// - build the sum of all relative column width values (if any)
$abs_sum = 0;
$table_column_styles = $this->getTableColumnStyles();
$replace = true;
for ($index = 0 ; $index < $this->getTableMaxColumns() ; $index++ ) {
$style_name = $table_column_styles [$index];
$style_obj = $params->document->getStyle($style_name);
if ($style_obj != NULL) {
if ($style_obj->getProperty('rel-column-width') != NULL) {
$width = $style_obj->getProperty('rel-column-width');
$length = strlen ($width);
$width = trim ($width, '*');
// Add column style object to relative array
// We need convert it to an absolute width
$entry = array();
$entry ['width'] = $width;
$entry ['obj'] = $style_obj;
$relative [] = $entry;
$abs_sum += (($width/10)/100) * $maxWidth;
$onlyAbsWidthFound = false;
$anyWidthFound = true;
} else if ($style_obj->getProperty('column-width') != NULL) {
$width = $style_obj->getProperty('column-width');
$length = strlen ($width);
$width = $params->document->toPoints($width, 'x');
$abs_sum += (float) trim ($width, 'pt');
$anyWidthFound = true;
} else {
// Add column style object to empty array
// We need to assign a width to this column
$empty [] = $style_obj;
$onlyAbsWidthFound = false;
}
}
}
// Convert max width to points
$maxWidth = $params->units->toPoints($maxWidth);
$maxWidth = $params->units->getDigits($maxWidth);
// The remaining absolute width is the max width minus the sum of
// all absolute width values
$absWidthLeft = $maxWidth - $abs_sum;
// Calculate the relative width left
// (e.g. if the absolute width is the half of the max width
// then the relative width left if 50%)
if ($maxWidth != 0) {
$relWidthLeft = 100-(($absWidthLeft/$maxWidth)*100);
}
// Give all empty columns a width
$maxEmpty = count($empty);
foreach ($empty as $column) {
//$width = ($relWidthLeft/$maxEmpty) * $absWidthLeft;
$width = $absWidthLeft/$maxEmpty;
$column->setProperty('column-width', $width.'pt');
$column->setProperty('rel-column-width', NULL);
}
// Convert all relative width to absolute
foreach ($relative as $column) {
$width = (($column ['width']/10)/100) * $maxWidth;
$column ['obj']->setProperty('column-width', $width.'pt');
$column ['obj']->setProperty('rel-column-width', NULL);
}
// If all columns have a fixed absolute width set then that means
// the table shall have the width of all comuns added together
// and not the maximum available width. Return $abs_sum.
if ($onlyAbsWidthFound && $anyWidthFound) {
return $abs_sum;
}
return $maxWidth;
}
}

View File

@@ -0,0 +1,173 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementTableCell:
* Class for handling the table cell element.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementTableCell extends ODTStateElement
{
protected $colspan;
protected $rowspan;
protected $value_type = 'string';
/**
* Constructor.
*/
public function __construct($style_name=NULL, $colspan = 1, $rowspan = 1) {
parent::__construct();
$this->setClass ('table-cell');
if ($style_name != NULL) {
$this->setStyleName ($style_name);
}
$this->setColumnSpan($colspan);
$this->setRowSpan($rowspan);
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('table:table-cell');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
$colspan = $this->getColumnSpan();
$rowspan = $this->getRowSpan();
$encoded = '<table:table-cell office:value-type="'.$this->getValueType().'"';
$encoded .= ' table:style-name="'.$this->getStyleName().'"';
if ( $colspan > 1 ) {
$encoded .= ' table:number-columns-spanned="'.$colspan.'"';
}
if ($rowspan > 1) {
$encoded .= ' table:number-rows-spanned="'.$rowspan.'"';
}
$encoded .= '>';
return $encoded;
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
$content = '</table:table-cell>';
$colspan = $this->getColumnSpan();
for ($i = 1 ; $i < $colspan ; $i++) {
$content .= '<table:covered-table-cell/>';
}
return $content;
}
/**
* Are we in a paragraph or not?
* As a table cell we are not.
*
* @return boolean
*/
public function getInParagraph() {
return false;
}
/**
* Determine and set the parent for this element.
* As a table cell our parent is the table element.
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
while ($previous != NULL) {
if ($previous->getClass() == 'table') {
break;
}
$previous = $previous->getParent();
}
$this->setParent($previous);
$curr_column = $previous->getTableCurrentColumn();
$curr_column++;
$previous->setTableCurrentColumn($curr_column);
// Eventually increase max columns if out range
$max_columns = $previous->getTableMaxColumns();
if ( $curr_column > $max_columns ) {
$previous->setTableMaxColumns($max_columns + 1);
}
}
/**
* Return the table to which this column belongs.
*
* @return ODTStateElement
*/
public function getTable () {
return $this->getParent();
}
/**
* Set the number of columns spanned by this cell.
*
* @param integer $value
*/
public function setColumnSpan($value) {
$this->colspan = $value;
}
/**
* Get the number of columns spanned by this cell.
*
* @return integer
*/
public function getColumnSpan() {
return $this->colspan;
}
/**
* Set the number of rows spanned by this cell.
*
* @param integer $value
*/
public function setRowSpan($value) {
$this->rowspan = $value;
}
/**
* Get the number of rows spanned by this cell.
*
* @return integer
*/
public function getRowSpan() {
return $this->rowspan;
}
/**
* Set the office value type for this cell.
*
* @param string $value
*/
public function setValueType($value) {
$this->value_type = $value;
}
/**
* Get the office value type for this cell.
*
* @return string
*/
public function getValueType() {
return $this->value_type;
}
}

View File

@@ -0,0 +1,148 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementTableColumn:
* Class for handling the table column element.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementTableColumn extends ODTStateElement
{
// Which column number in the corresponding table is this?
// [Is set on enter() ==> determineParent()]
protected $columnNumber = 0;
/**
* Constructor.
*/
public function __construct() {
parent::__construct();
$this->setClass ('table-column');
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('table:table-column');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
return '<table:table-column table:style-name="'.$this->getStyleName().'"/>';
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
return '</table:table-column>';
}
/**
* Are we in a paragraph or not?
* As a table column we are not.
*
* @return boolean
*/
public function getInParagraph() {
return false;
}
/**
* Determine and set the parent for this element.
* As a table column our parent is the table element.
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
$table = $previous;
while ($table != NULL) {
if ($table->getClass() == 'table') {
break;
}
$table = $table->getParent();
}
$this->setParent($table);
if ($table == NULL) {
// ??? Should not be...
return;
}
// Overwrite/Create column style for actual column if $properties has any
// meaningful params for a column-style (e.g. width).
$table_column_styles = $table->getTableColumnStyles();
$auto_columns = $table->getTableAutoColumns();
$max_columns = $table->getTableMaxColumns();
$row_count = $table->getRowCount();
$curr_column = $table->getTableCurrentColumn();
if ($row_count > 0) {
$curr_column--;
}
// Set our column number.
$this->columnNumber = $curr_column;
// Set our style name to a predefined name
// and also set it in the table (if not done yet)
$style_name = $table->getTableColumnStyleName($curr_column);
if (empty($style_name)) {
$style_name = 'odt_auto_style_table_column_'.$table->getCount().'_'.($curr_column+1);
$table->setTableColumnStyleName($curr_column, $style_name);
}
$this->setStyleName ($style_name);
if ($row_count == 0) {
// Only count columns here if not already a row has been opened.
// Otherwise counting will be done in ODTElementTableCell!
$curr_column++;
$table->setTableCurrentColumn($curr_column);
// Eventually increase max columns if out range
if ( $curr_column > $max_columns ) {
$table->setTableMaxColumns($max_columns + 1);
}
}
}
/**
* Set the style name.
* The method is overwritten to make the column also set the new
* column style name in its corresponding table.
*
* FIXME: it would be better to just have an array of object
* pointers in the table and use them to query the names.
*
* @param string $value Style name, e.g. 'body'
*/
public function setStyleName($value) {
parent::setStyleName($value);
$table = $this->getParent();
if ($table != NULL) {
$table->setTableColumnStyleName($this->columnNumber, $value);
} else {
// FIXME: some error logging would be nice...
}
}
/**
* Return the table to which this column belongs.
*
* @return ODTStateElement
*/
public function getTable () {
return $this->getParent();
}
}

View File

@@ -0,0 +1,57 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementTableHeaderCell:
* Class for handling the table "header" cell element.
*
* In ODT there is no header cell element so this is just a normal
* table cell with some extra handling for the automatic column
* count mode.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementTableHeaderCell extends ODTElementTableCell
{
/**
* Constructor.
*/
public function __construct($style_name=NULL, $colspan = 0, $rowspan = 0) {
parent::__construct($style_name, $colspan, $rowspan);
$this->setClass ('table-header');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
$colspan = $this->getColumnSpan();
$rowspan = $this->getRowSpan();
// Get our corresponding table.
$table = $this->getTable();
$auto_columns = false;
$count = 0;
if ($table != NULL) {
$auto_columns = $table->getTableAutoColumns();
$count = $table->getCount();
}
$encoded = '<table:table-cell office:value-type="'.$this->getValueType().'"';
$encoded .= ' table:style-name="'.$this->getStyleName().'"';
if ( $colspan > 1 ) {
$encoded .= ' table:number-columns-spanned="'.$colspan.'"';
} else if ($auto_columns === true && $colspan == 0) {
$encoded .= ' table:number-columns-spanned="<MaxColsPlaceholder'.$count.'>"';
}
if ( $rowspan > 1 ) {
$encoded .= ' table:number-rows-spanned="'.$rowspan.'"';
}
$encoded .= '>';
return $encoded;
}
}

View File

@@ -0,0 +1,110 @@
<?php
/**
* Handle ODT Table row elements.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
* @package ODT\Elements\ODTElementTableRow
*/
/** Include ODTStateElement */
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementTableRow:
* Class for handling the table row element.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementTableRow extends ODTStateElement
{
/**
* Constructor.
*
* @param string $style_name Name of the style
*/
public function __construct($style_name=NULL) {
parent::__construct();
$this->setClass ('table-row');
if ($style_name != NULL) {
$this->setStyleName ($style_name);
}
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('table:table-row');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
$style_name = $this->getStyleName();
if ($style_name != NULL) {
return '<table:table-row table:style-name="'.$style_name.'">';
}
return '<table:table-row>';
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
return '</table:table-row>';
}
/**
* Are we in a paragraph or not?
* As a table row we are not.
*
* @return boolean
*/
public function getInParagraph() {
return false;
}
/**
* Determine and set the parent for this element.
* As a table row our parent is the table element.
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
$table = $previous;
while ($table != NULL) {
if ($table->getClass() == 'table') {
break;
}
$table = $table->getParent();
}
$this->setParent($table);
if ($table == NULL) {
// ??? Should not be...
return;
}
// A new row, we are back in the first column again.
$table->increaseRowCount();
$table->setTableCurrentColumn(0);
}
/**
* Return the table to which this column belongs.
*
* @return ODTStateElement
*/
public function getTable () {
return $this->getParent();
}
}

View File

@@ -0,0 +1,89 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementTextBox:
* Class for handling the text box element.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementTextBox extends ODTStateElement
{
protected $attributes = NULL;
/**
* Constructor.
*/
public function __construct() {
parent::__construct();
$this->setClass ('text-box');
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
return ('draw:text-box');
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
$encoded = '<draw:text-box '.$this->getAttributes().'>';
return $encoded;
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
return '</draw:text-box>';
}
/**
* Are we in a paragraph or not?
* As a text box we are not.
*
* @return boolean
*/
public function getInParagraph() {
return false;
}
/**
* Determine and set the parent for this element.
* As a text box the previous element is our parent.
*
* @param ODTStateElement $previous
*/
public function determineParent(ODTStateElement $previous) {
$this->setParent($previous);
}
/**
* Set text box attributes
*
* @param array $value
*/
public function setAttributes($value) {
$this->attributes = $value;
}
/**
* Get text box attributes
*
* @return array
*/
public function getAttributes() {
return $this->attributes;
}
}

View File

@@ -0,0 +1,80 @@
<?php
require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
/**
* ODTElementRoot:
* Root-Element to make things easier. Always needs to be on top of ODTState.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
class ODTElementRoot extends ODTStateElement
{
/**
* Constructor.
*/
public function __construct() {
parent::__construct();
$this->setClass ('root');
$this->setCount (1);
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
public function getElementName () {
// Dummy.
return 'root';
}
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
public function getOpeningTag () {
// Dummy.
return '';
}
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
public function getClosingTag () {
// Dummy.
return '';
}
/**
* Set parent dummy function for preventing that anyone
* accidentally sets a parent for the root.
*
* @param ODTStateElement $parent_element
*/
public function setParent(ODTStateElement $parent_element) {
// Intentionally do nothing!
}
/**
* Are we in a paragraph or not?
* This is the root - so we are not.
*
* @return boolean
*/
public function getInParagraph() {
return false;
}
/**
* Determine and set the parent for this element.
* Nothing to do for the root.
*/
public function determineParent(ODTStateElement $previous) {
// Intentionally do nothing!
}
}

View File

@@ -0,0 +1,193 @@
<?php
/**
* ODTStateElement:
* Base class for all elements which are added/used with class ODTState.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author LarsDW223
*/
abstract class ODTStateElement
{
// General state information
protected $clazz = NULL;
protected $style_name = NULL;
protected $count = 0;
protected $parent_element = NULL;
protected $style_obj = NULL;
protected $htmlElement = NULL;
// Temp pointer for various use! Can point to different things!
protected $temp = NULL;
/**
* Constructor.
*/
public function __construct($style_name=NULL) {
// Empty for now.
// All elements call the parent constructor so it might be
// of use in the future...
}
/**
* Set the class to $value.
*
* @param string $value Class, e.g. 'paragraph'
*/
public function setClass($value) {
$this->clazz = $value;
}
/**
* Get the class.
*
* @return string Class.
*/
public function getClass() {
return $this->clazz;
}
/**
* Set the element count to $value.
* If e.g. the element is 'table', then the count specifies
* that this element is table number '$value'.
*
* @param string $value Count
*/
public function setCount($value) {
$this->count = $value;
}
/**
* Get the element count.
*
* @return integer Count.
*/
public function getCount() {
return $this->count;
}
/**
* Set the style name.
*
* @param string $value Style name, e.g. 'body'
*/
public function setStyleName($value) {
$this->style_name = $value;
}
/**
* Get the style name.
*
* @return string Style name.
*/
public function getStyleName() {
return $this->style_name;
}
/**
* Set the style object.
*
* @param ODTStyle $object
*/
public function setStyle($object) {
$this->style_obj = $object;
}
/**
* Get the style object.
*
* @return ODTStyle Style object.
*/
public function getStyle() {
return $this->style_obj;
}
/**
* Set temporary data for various use.
*
* @param mixed $value
*/
public function setTemp($value) {
$this->temp = $value;
}
/**
* Get temporary data for various use.
*
* @return mixed
*/
public function getTemp() {
return $this->temp;
}
/**
* Set parent of this element.
*
* @param ODTStateElement $parent_element
*/
public function setParent(ODTStateElement $parent_element) {
$this->parent_element = $parent_element;
}
/**
* Get parent of this element.
*
* @return ODTStateElement
*/
public function getParent() {
return $this->parent_element;
}
/**
* Return the elements name.
*
* @return string The ODT XML element name.
*/
abstract public function getElementName ();
/**
* Return string with encoded opening tag.
*
* @return string The ODT XML code to open this element.
*/
abstract public function getOpeningTag ();
/**
* Return string with encoded closing tag.
*
* @return string The ODT XML code to close this element.
*/
abstract public function getClosingTag ();
/**
* Are we in a paragraph or not?
*
* @return boolean
*/
abstract public function getInParagraph();
/**
* Determine and set the parent for this element.
* The search starts at element $previous.
*/
abstract public function determineParent(ODTStateElement $previous);
/**
* Set the HTML element name pushed to the HTML stack for this ODT element.
*
* @param string $value HTML element name e.g. 'u'
*/
public function setHTMLElement($value) {
$this->htmlElement = $value;
}
/**
* Get the HTML element name pushed to the HTML stack for this ODT element.
*
* @return string HTML element name.
*/
public function getHTMLElement() {
return $this->htmlElement;
}
}