|
@@ -4,7 +4,7 @@
|
|
|
*
|
|
|
* Requires PHP 5.2
|
|
|
*
|
|
|
- * @version $Id: Calc_Cell.php,v 1.2 2007-08-06 06:17:06 marand Exp $
|
|
|
+ * @version $Id: Calc_Cell.php,v 1.3 2007-09-09 19:50:22 marand Exp $
|
|
|
* @license CeCILL 2.0
|
|
|
* @copyright 2005-2006 Ouest Systemes Informatiques
|
|
|
*/
|
|
@@ -22,40 +22,56 @@ class Calc_Cell
|
|
|
const TYPE_STRING = 'string';
|
|
|
const TYPE_FLOAT = 'float';
|
|
|
const TYPE_EMPTY = 'empty';
|
|
|
-
|
|
|
+
|
|
|
public $dataType;
|
|
|
public $dataValue;
|
|
|
public $displayValue;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
* @param DOMNode $cellNode
|
|
|
*/
|
|
|
function __construct(DOMNode $cellNode)
|
|
|
{
|
|
|
- if (is_a($cellNode, 'DOMElement'))
|
|
|
+ if ($cellNode instanceof DOMElement)
|
|
|
{
|
|
|
$this->dataType = $cellNode->getAttributeNS(Calc_Reader::NS_OFFICE, 'value-type');
|
|
|
-
|
|
|
- * Note: cells with office:value-type==string don't have a office:value
|
|
|
- * attribute, but it is clearer to just fetch it and get NULL than test.
|
|
|
- * Maybe more sophistication will be needed in the future
|
|
|
- */
|
|
|
- $this->dataValue = $cellNode->getAttributeNS(Calc_Reader::NS_OFFICE, 'value');
|
|
|
- $p = $cellNode->childNodes->item(0);
|
|
|
- $this->displayValue = $p->textContent;
|
|
|
- unset($p);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- $this->dataType = Calc_Cell::TYPE_EMPTY;
|
|
|
- $this->dataValue = NULL;
|
|
|
- $this->displayValue = '';
|
|
|
+
|
|
|
+ if ($cellNode->childNodes->length == 0)
|
|
|
+ {
|
|
|
+ $this->dataType = Calc_Cell::TYPE_EMPTY;
|
|
|
+ $this->dataValue = NULL;
|
|
|
+ $this->displayValue = '';
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $p = $cellNode->childNodes->item(0);
|
|
|
+ $this->displayValue = $p->textContent;
|
|
|
+ unset($p);
|
|
|
+
|
|
|
+
|
|
|
+ * Note: cells with office:value-type==string don't have a office:value
|
|
|
+ */
|
|
|
+ if ($this->dataType == Calc_Cell::TYPE_STRING)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $this->dataValue = $cellNode->getAttributeNS(Calc_Reader::NS_OFFICE, 'value');
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ . ", type = " . $this->dataType
|
|
|
+ . ", value = " . substr($this->dataValue, 0, 20)
|
|
|
+ . ", display = <" . substr($this->displayValue, 0, 20)
|
|
|
+ . ">" . PHP_EOL; */
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
* Convert a PHP value to a wrapped OpenDocument cell value
|
|
|
- *
|
|
|
+ *
|
|
|
* @param mixed $x
|
|
|
*/
|
|
|
function set($x = NULL)
|
|
@@ -64,7 +80,7 @@ class Calc_Cell
|
|
|
switch ($type)
|
|
|
{
|
|
|
case 'NULL':
|
|
|
- $this->dataType = Calc_Cell::TYPE_EMPTY;
|
|
|
+ $this->dataType = Calc_Cell::TYPE_EMPTY;
|
|
|
$this->dataValue = NULL;
|
|
|
$this->displayValue = NULL;
|
|
|
break;
|
|
@@ -84,10 +100,10 @@ class Calc_Cell
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
* implement magic method __toString
|
|
|
- *
|
|
|
+ *
|
|
|
* @return string
|
|
|
*/
|
|
|
function __toString()
|