php__phplib/OSInet/Open_Document/Calc/Row.php
Frederic G. MARAND 6a058cd843 Converted the OSInet ODF Calc reader classes to PSR0
- classes are now namespace.
- added a demo in apps/odf_calc_reader.
- added associated cleanup in Makefile.
2012-05-05 22:58:31 +02:00

60 lines
1.3 KiB
PHP

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