diff options
-rw-r--r-- | sc/inc/units.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/units.cxx | 1 | ||||
-rw-r--r-- | sc/source/core/units/unitsimpl.cxx | 40 | ||||
-rw-r--r-- | sc/source/core/units/unitsimpl.hxx | 2 |
4 files changed, 24 insertions, 21 deletions
diff --git a/sc/inc/units.hxx b/sc/inc/units.hxx index b5e12da42909..8e15af4a8a00 100644 --- a/sc/inc/units.hxx +++ b/sc/inc/units.hxx @@ -107,7 +107,7 @@ public: * rsInputUnit overrides the automatic determination of input units, i.e. disables * input unit detection. */ - virtual bool convertCellUnits(const ScRange& rRange, + virtual bool convertCellUnits(const ScRangeList& rRanges, ScDocument* pDoc, const OUString& rsOutputUnit) = 0; diff --git a/sc/qa/unit/units.cxx b/sc/qa/unit/units.cxx index 29dfc2b7c626..b35cd4059320 100644 --- a/sc/qa/unit/units.cxx +++ b/sc/qa/unit/units.cxx @@ -820,6 +820,7 @@ void UnitsTest::testRangeConversion() { // TODO: we need to test: // 1. mixture of units that can't be converted // 2. mixtures of local and header annotations + // 3. actual sensible ranges } CPPUNIT_TEST_SUITE_REGISTRATION(UnitsTest); diff --git a/sc/source/core/units/unitsimpl.cxx b/sc/source/core/units/unitsimpl.cxx index f2aa9e0e3315..0f79edb9e295 100644 --- a/sc/source/core/units/unitsimpl.cxx +++ b/sc/source/core/units/unitsimpl.cxx @@ -799,7 +799,7 @@ bool UnitsImpl::convertCellUnitsForColumnRange(const ScRange& rRange, return bAllConverted; } -bool UnitsImpl::convertCellUnits(const ScRange& rRange, +bool UnitsImpl::convertCellUnits(const ScRangeList& rRangeList, ScDocument* pDoc, const OUString& rsOutputUnit) { UtUnit aOutputUnit; @@ -807,26 +807,28 @@ bool UnitsImpl::convertCellUnits(const ScRange& rRange, return false; } - ScRange aRange(rRange); - aRange.PutInOrder(); - - SCCOL nStartCol, nEndCol; - SCROW nStartRow, nEndRow; - SCTAB nStartTab, nEndTab; - aRange.GetVars(nStartCol, nStartRow, nStartTab, - nEndCol, nEndRow, nEndTab); - - // Can only handle ranges in a single sheet for now - assert(nStartTab == nEndTab); - - // Each column is independent hence we are able to handle each separately. bool bAllConverted = true; - for (SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++) { - ScRange aSubRange(ScAddress(nCol, nStartRow, nStartTab), ScAddress(nCol, nEndRow, nStartTab)); - bAllConverted = bAllConverted && - convertCellUnitsForColumnRange(aSubRange, pDoc, aOutputUnit); - } + for (size_t i = 0; i < rRangeList.size(); i++) { + ScRange aRange(*rRangeList[i]); + + aRange.PutInOrder(); + + SCCOL nStartCol, nEndCol; + SCROW nStartRow, nEndRow; + SCTAB nStartTab, nEndTab; + aRange.GetVars(nStartCol, nStartRow, nStartTab, + nEndCol, nEndRow, nEndTab); + + // Each column is independent hence we are able to handle each separately. + for (SCTAB nTab = nStartTab; nTab <= nEndTab; nTab++) { + for (SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++) { + ScRange aSubRange(ScAddress(nCol, nStartRow, nTab), ScAddress(nCol, nEndRow, nTab)); + bAllConverted = bAllConverted && + convertCellUnitsForColumnRange(aSubRange, pDoc, aOutputUnit); + } + } + } return bAllConverted; } diff --git a/sc/source/core/units/unitsimpl.hxx b/sc/source/core/units/unitsimpl.hxx index e7b4597840c0..58e0971cfe68 100644 --- a/sc/source/core/units/unitsimpl.hxx +++ b/sc/source/core/units/unitsimpl.hxx @@ -103,7 +103,7 @@ public: const OUString& rsNewUnit, const OUString& rsOldUnit) SAL_OVERRIDE; - virtual bool convertCellUnits(const ScRange& rRange, + virtual bool convertCellUnits(const ScRangeList& rRanges, ScDocument* pDoc, const OUString& rsOutputUnit) SAL_OVERRIDE; |