2016-03-06 08:05:32 +00:00
|
|
|
package com.bytezone.diskbrowser.visicalc;
|
|
|
|
|
2017-02-18 09:54:24 +00:00
|
|
|
class Count extends Function
|
2016-03-06 08:05:32 +00:00
|
|
|
{
|
2017-02-18 09:54:24 +00:00
|
|
|
private final Range range;
|
|
|
|
|
2016-03-06 08:05:32 +00:00
|
|
|
public Count (Sheet parent, String text)
|
|
|
|
{
|
2016-03-09 10:38:53 +00:00
|
|
|
super (parent, text);
|
2017-02-18 09:54:24 +00:00
|
|
|
range = new Range (text);
|
2016-03-06 08:05:32 +00:00
|
|
|
}
|
|
|
|
|
2016-03-12 05:05:50 +00:00
|
|
|
@Override
|
2016-03-17 04:40:43 +00:00
|
|
|
public Value calculate ()
|
2016-03-12 05:05:50 +00:00
|
|
|
{
|
2016-03-16 06:15:39 +00:00
|
|
|
value = 0;
|
2016-03-17 04:40:43 +00:00
|
|
|
valueType = ValueType.VALUE;
|
|
|
|
|
2016-03-06 08:05:32 +00:00
|
|
|
for (Address address : range)
|
|
|
|
{
|
|
|
|
Cell cell = parent.getCell (address);
|
2016-08-01 05:18:51 +00:00
|
|
|
if (cell == null || cell.isValueType (ValueType.NA))
|
2016-03-17 04:40:43 +00:00
|
|
|
continue;
|
|
|
|
|
2017-02-25 03:56:22 +00:00
|
|
|
if (!cell.isValueType (ValueType.VALUE))
|
2016-03-12 05:05:50 +00:00
|
|
|
{
|
2017-02-25 03:56:22 +00:00
|
|
|
valueType = cell.getValueType ();
|
2016-03-16 06:15:39 +00:00
|
|
|
break;
|
2016-03-12 05:05:50 +00:00
|
|
|
}
|
2016-03-16 06:15:39 +00:00
|
|
|
|
|
|
|
if (cell.getValue () != 0.0)
|
|
|
|
value++;
|
2016-03-06 08:05:32 +00:00
|
|
|
}
|
2016-07-21 11:08:28 +00:00
|
|
|
|
2016-03-17 04:40:43 +00:00
|
|
|
return this;
|
2016-03-06 08:05:32 +00:00
|
|
|
}
|
|
|
|
}
|