123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- /**
- * Wrap an OpenDocument spreadsheet row
- *
- * Requires PHP 5.3
- *
- * @license CeCILL 2.0
- * @copyright 2005-2012 Ouest Systemes Informatiques
- */
- namespace Osinet\OpenDocument\Calc;
- class Row {
- /**
- * @var \DOMElement $row
- */
- protected $row;
- /**
- * Construct a Row from the DOMElement representing it.
- *
- * This DOMElement must bear a table:table-row tag
- *
- * @param \DOMElement $row
- *
- * @return void
- */
- function __construct(\DOMElement $row) {
- if ((!($row instanceof \DOMElement)) || ($row->tagName != 'table:table-row')) {
- die('Row::__construct() needs a DOMElement parameter for a table-row element ');
- }
- $this->row = $row;
- }
- /**
- * Analyze a spreadsheet row and return the cells as an array of Calc_Cell
- *
- * @return array<\Osinet\OpenDocument\Calc\Cell>
- */
- function getCells(): array {
- $cellNodeList = $this->row->childNodes;
- $cells = [];
- $iCell = 0;
- for ($icol = 0; $icol < $cellNodeList->length; $icol++) {
- $cellNode = $cellNodeList->item($icol);
- $count = NULL;
- if ($cellNode instanceof \DOMElement) {
- $count = $cellNode->getAttributeNS(Reader::NS_TABLE, 'number-columns-repeated');
- }
- if (empty($count)) {
- $count = 1;
- }
- for ($j = 0; $j < $count; $j++) {
- $cells[$iCell++] = new Cell($cellNode);
- }
- }
- return $cells;
- }
- }
|