Skip to content

Commit

Permalink
Merge pull request #1561 from joebordes/hacktoberfest20235
Browse files Browse the repository at this point in the history
fix(GenDoc) support tables inside sections
  • Loading branch information
joebordes committed Oct 26, 2023
2 parents 79e4332 + 51aca7b commit 0d006d7
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/evvtgendoc/OpenDocument/Section.php
Expand Up @@ -77,6 +77,7 @@ public function __construct(DOMNode $node, OpenDocument $document) {
'OpenDocument_Paragraph',
'OpenDocument_Heading',
'OpenDocument_List',
'OpenDocument_Table',
);
}

Expand Down Expand Up @@ -130,5 +131,9 @@ public function createHeading($text = '', $level = 1) {
public function createList() {
return OpenDocument_List::instance($this);
}

public function createTable($subtable = '') {
return OpenDocument_Table::instance($this, $subtable);
}
}
?>
10 changes: 10 additions & 0 deletions modules/evvtgendoc/OpenDocument/Table.php
Expand Up @@ -82,6 +82,13 @@ class OpenDocument_Table extends OpenDocument_StyledElement {
*/
public function __construct(DOMNode $node, OpenDocument $document, $subtable = '') {
parent::__construct($node, $document);
$this->allowedElements = array(
'OpenDocument_TableHeaderRow',
'OpenDocument_TableRow',
'OpenDocument_TableColumn',
'OpenDocument_Span',
'OpenDocument_TextElement',
);
return true;
}

Expand Down Expand Up @@ -306,6 +313,9 @@ public function getDocumentFragment() {
* @access public
*/
public function getChildren() {
if (empty($this->children)) {
$this->listChildren();
}
return $this->children->getIterator();
}
}
Expand Down
9 changes: 9 additions & 0 deletions modules/evvtgendoc/OpenDocument/TableCell.php
Expand Up @@ -75,6 +75,12 @@ class OpenDocument_TableCell extends OpenDocument_StyledElement {
*/
public function __construct(DOMNode $node, OpenDocument $document, $colspan = '', $rowspan = '') {
parent::__construct($node, $document);
$this->allowedElements = array(
'OpenDocument_Table',
'OpenDocument_Paragraph',
'OpenDocument_TextElement',
'OpenDocument_Heading',
);
return true;
}

Expand Down Expand Up @@ -201,6 +207,9 @@ public function createHeading($text = '', $level = 1) {
* @access public
*/
public function getChildren() {
if (empty($this->children)) {
$this->listChildren();
}
return $this->children->getIterator();
}
}
Expand Down
18 changes: 18 additions & 0 deletions modules/evvtgendoc/OpenDocument/TableHeaderRow.php
Expand Up @@ -64,6 +64,21 @@ class OpenDocument_TableHeaderRow extends OpenDocument_StyledElement {
*/
const styleNamePrefix = 'T';

/**
* Constructor
*
* @param DOMNode $node
* @param OpenDocument $document
*/
public function __construct(DOMNode $node, OpenDocument $document) {
parent::__construct($node, $document);
$this->allowedElements = array(
'OpenDocument_TableCoveredCell',
'OpenDocument_TableCell',
'OpenDocument_TableRow',
);
}

/**
* Create element instance
*
Expand Down Expand Up @@ -180,6 +195,9 @@ public function createTableCoveredCell() {
* @access public
*/
public function getChildren() {
if (empty($this->children)) {
$this->listChildren();
}
return $this->children->getIterator();
}
}
Expand Down
18 changes: 18 additions & 0 deletions modules/evvtgendoc/OpenDocument/TableRow.php
Expand Up @@ -64,6 +64,21 @@ class OpenDocument_TableRow extends OpenDocument_StyledElement {
*/
const styleNamePrefix = 'T';

/**
* Constructor
*
* @param DOMNode $node
* @param OpenDocument $document
*/
public function __construct(DOMNode $node, OpenDocument $document) {
parent::__construct($node, $document);
$this->allowedElements = array(
'OpenDocument_TableCoveredCell',
'OpenDocument_TableCell',
'OpenDocument_TextElement',
);
}

/**
* Create element instance
*
Expand Down Expand Up @@ -179,6 +194,9 @@ public function createTableCoveredCell() {
* @access public
*/
public function getChildren() {
if (empty($this->children)) {
$this->listChildren();
}
return $this->children->getIterator();
}
}
Expand Down

0 comments on commit 0d006d7

Please sign in to comment.