summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej@ahunt.org>2015-04-01 14:54:20 +0200
committerAndrzej Hunt <andrzej@ahunt.org>2015-10-20 18:18:28 +0200
commit0e6b950c5acb7fb08c1164b9046bdf26a964a436 (patch)
treeb86d90490cc3c9841c0201f0791600a3f2e354f6
parent0625da7e5dec271ff89154374897e89861299477 (diff)
Check output unit against header definition during verification.
Change-Id: I98a706d80eb442d274fc111fb6c22e43d79fb9ff
-rw-r--r--sc/source/core/units/unitsimpl.cxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/sc/source/core/units/unitsimpl.cxx b/sc/source/core/units/unitsimpl.cxx
index fbd0c2d691ec..99e03af800a0 100644
--- a/sc/source/core/units/unitsimpl.cxx
+++ b/sc/source/core/units/unitsimpl.cxx
@@ -616,7 +616,23 @@ bool UnitsImpl::verifyFormula(ScTokenArray* pArray, const ScAddress& rFormulaAdd
}
}
- // TODO: only fail if actual parsing fails?
+ if (aStack.size() != 1) {
+ SAL_WARN("sc.units", "Wrong number of units on stack, should be 1, actual number: " << aStack.size());
+ return false;
+ } else if (aStack.top().type != StackItemType::UNITS) {
+ SAL_WARN("sc.units", "End of verification: item on stack does not contain units");
+ return false;
+ }
+
+ OUString sUnitString;
+ ScAddress aAddress;
+
+ UtUnit aHeaderUnit = findHeaderUnitForCell(rFormulaAddress, pDoc, sUnitString, aAddress);
+ UtUnit aResultUnit = boost::get< UtUnit>(aStack.top().item);
+
+ if (aHeaderUnit.isValid() && aHeaderUnit != aResultUnit) {
+ return false;
+ }
return true;
}