summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej@ahunt.org>2015-05-12 20:15:15 +0100
committerAndrzej Hunt <andrzej@ahunt.org>2015-10-20 18:18:33 +0200
commit611220c4a41967170e0cc760fbe16eb67425180a (patch)
tree5c03927e99467e847ec60bfde1a6aabae6753b61
parent9be7dafa0c6ddb92151d97a7d5adc30784f94e81 (diff)
Return invalid unit for empty and string cells.
Change-Id: I6dbec9be643040f9fc567e6065f860a3985f138a
-rw-r--r--sc/source/core/units/unitsimpl.cxx5
-rw-r--r--sc/source/core/units/unitsimpl.hxx2
2 files changed, 7 insertions, 0 deletions
diff --git a/sc/source/core/units/unitsimpl.cxx b/sc/source/core/units/unitsimpl.cxx
index a7b103f31bf9..a67871d55cfa 100644
--- a/sc/source/core/units/unitsimpl.cxx
+++ b/sc/source/core/units/unitsimpl.cxx
@@ -441,6 +441,11 @@ HeaderUnitDescriptor UnitsImpl::extractUnitFromHeaderString(const OUString& rsHe
}
UtUnit UnitsImpl::getUnitForCell(const ScAddress& rCellAddress, ScDocument* pDoc) {
+ CellType aType(pDoc->GetCellType(rCellAddress));
+ if (aType == CELLTYPE_STRING || aType == CELLTYPE_NONE) {
+ return UtUnit();
+ }
+
OUString sUnitString = extractUnitStringForCell(rCellAddress, pDoc);
UtUnit aUnit;
diff --git a/sc/source/core/units/unitsimpl.hxx b/sc/source/core/units/unitsimpl.hxx
index ff30232b2d19..88975b8e0015 100644
--- a/sc/source/core/units/unitsimpl.hxx
+++ b/sc/source/core/units/unitsimpl.hxx
@@ -144,6 +144,8 @@ private:
* Retrieve the units for a given cell. This probes based on the usual rules
* for cell annotation/column header.
* Retrieving units for a formula cell is not yet supported.
+ *
+ * Units are undefined for any text cell (including header cells).
*/
UtUnit getUnitForCell(const ScAddress& rCellAddress, ScDocument* pDoc);
UtUnit getUnitForRef(formula::FormulaToken* pToken,