if(err!=null) return err.getString();
if(result instanceof String && !((String) result).isEmpty()){
- return FormulaError2.VALUE.getString();
+ Number num = SpreadsheetGraphUtils.asValidNumber(result);
+ if(num == null) {
+ return FormulaError2.VALUE.getString();
+ } else {
+ result = num;
+ }
}
else if(result instanceof Variant){
Object val = ((Variant)result).getValue();
if(err!=null) return err.getString();
if(result instanceof String && !((String) result).isEmpty()){
- return FormulaError2.VALUE.getString();
+ Number num = SpreadsheetGraphUtils.asValidNumber(result);
+ if(num == null) {
+ return FormulaError2.VALUE.getString();
+ } else {
+ result = num;
+ }
}
else if(result instanceof Variant){
Object val = ((Variant)result).getValue();
private CellEditor<Write> getPossibleCellEditor(WriteGraph graph, String location, Variant value) throws DatabaseException {
SpreadsheetResource SHEET = SpreadsheetResource.getInstance(graph);
- Range range = SpreadsheetUtils.decodeCellAbsolute(location);
-
- List<Variable> cells = SpreadsheetGraphUtils.possibleConfigurationCellVariables(graph, sheet, range);
- if (cells.isEmpty()) {
- if (value == null) {
- return null;
- } else {
- cells = SpreadsheetGraphUtils.getOrCreateConfigurationCellVariables(graph, sheet, range);
- }
- }
- if (cells.size() != 1)
- throw new DatabaseException("Can edit only one cell at a time!");
-
- return cells.iterator().next().getPropertyValue(graph, SHEET.cellEditor);
+ Range range = SpreadsheetUtils.decodePossibleCellAbsolute(location);
+ if(range == null) return null; //No editor found
+
+ List<Variable> cells = SpreadsheetGraphUtils.possibleConfigurationCellVariables(graph, sheet, range);
+ if (cells.isEmpty()) {
+ if (value == null) {
+ return null;
+ } else {
+ cells = SpreadsheetGraphUtils.getOrCreateConfigurationCellVariables(graph, sheet, range);
+ }
+ }
+ if (cells.size() != 1)
+ throw new DatabaseException("Can edit only one cell at a time!");
+
+ return cells.iterator().next().getPropertyValue(graph, SHEET.cellEditor);
}
@Override
expression = "";
} else {
expression = "=" + expression;
- }
+ }
+ //Don't update if the expression hasn't changed
if (expression.equals(str))
return;
if (str.startsWith("=")) {
editor.edit(null, SpreadsheetUtils.cellName(row, column), ClientModel.CONTENT_EXPRESSION, str, Bindings.STRING, null);
+ //Update cell expression
+ clientModel.setProperty(cellName, ClientModel.CONTENT_EXPRESSION, str);
} else {
editor.edit(null, SpreadsheetUtils.cellName(row, column), Variant.ofInstance(str), null);
+ //Update cell expression
+ clientModel.setProperty(cellName, ClientModel.CONTENT_EXPRESSION, null); //If not an expression, then the expression property is null
}
}