2016-03-06 08:05:32 +00:00
|
|
|
package com.bytezone.diskbrowser.visicalc;
|
|
|
|
|
2016-03-12 22:38:03 +00:00
|
|
|
class Sum extends Function
|
2016-03-06 08:05:32 +00:00
|
|
|
{
|
2016-03-12 05:05:50 +00:00
|
|
|
private final Range range;
|
2016-03-06 08:05:32 +00:00
|
|
|
|
|
|
|
public Sum (Sheet parent, String text)
|
|
|
|
{
|
2016-03-09 10:38:53 +00:00
|
|
|
super (parent, text);
|
2016-03-07 12:16:11 +00:00
|
|
|
range = getRange (text);
|
2016-03-06 08:05:32 +00:00
|
|
|
}
|
|
|
|
|
2016-03-12 05:05:50 +00:00
|
|
|
@Override
|
|
|
|
public void calculate ()
|
|
|
|
{
|
2016-03-16 06:15:39 +00:00
|
|
|
value = 0;
|
2016-03-16 19:32:25 +00:00
|
|
|
valueType = ValueType.VALUE;
|
|
|
|
|
2016-03-06 08:05:32 +00:00
|
|
|
for (Address address : range)
|
2016-03-06 23:52:46 +00:00
|
|
|
{
|
|
|
|
Cell cell = parent.getCell (address);
|
2016-03-16 06:15:39 +00:00
|
|
|
if (cell == null)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (cell.isError () || cell.isNaN ())
|
2016-03-12 05:05:50 +00:00
|
|
|
{
|
2016-03-16 19:32:25 +00:00
|
|
|
valueType = ValueType.ERROR;
|
|
|
|
return;
|
2016-03-12 05:05:50 +00:00
|
|
|
}
|
2016-03-16 06:15:39 +00:00
|
|
|
value += cell.getValue ();
|
2016-03-06 23:52:46 +00:00
|
|
|
}
|
2016-03-06 08:05:32 +00:00
|
|
|
}
|
|
|
|
}
|