diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-04-11 02:53:49 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-04-13 17:21:31 +0200 |
commit | ea35a682d2f5b508293e6dcef23629c435fcb6e1 (patch) | |
tree | bfa61bf48acd3febf21cd5b6df277c65fb6d3c95 /sw | |
parent | b845d236f530327610a6f69b0126c63693028e84 (diff) |
use getCells()
Change-Id: Ib3e115b7b96d0536db6917e84cfac7816176b296
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 588ad2539af9..4ab232d114a3 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3674,13 +3674,13 @@ void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno if(!pFmt) return; if(rArray.getLength() != nRowCount) - throw uno::RuntimeException("Row count mismatch", static_cast<cppu::OWeakObject*>(this)); + throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rArray.getLength()), static_cast<cppu::OWeakObject*>(this)); auto vCells(getCells()); auto pCurrentCell(vCells.begin()); for(const auto& rColSeq : rArray) { if(rColSeq.getLength() != nColCount) - throw uno::RuntimeException("Column count mismatch", static_cast<cppu::OWeakObject*>(this)); + throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rColSeq.getLength()), static_cast<cppu::OWeakObject*>(this)); for(const auto& aValue : rColSeq) { auto pCell(static_cast<SwXCell*>(pCurrentCell->get())); @@ -3706,16 +3706,16 @@ uno::Sequence< uno::Sequence< double > > SwXCellRange::getData(void) throw( uno: throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); if(m_bFirstColumnAsLabel || m_bFirstRowAsLabel) { - uno::Reference<chart::XChartDataArray> xDataRange(getCellRangeByPosition(m_bFirstRowAsLabel ? 1 : 0, m_bFirstColumnAsLabel ? 1 : 0, - nRowCount, nColCount), uno::UNO_QUERY); + uno::Reference<chart::XChartDataArray> xDataRange(getCellRangeByPosition(m_bFirstColumnAsLabel ? 1 : 0, m_bFirstRowAsLabel ? 1 : 0, + nColCount-1, nRowCount-1), uno::UNO_QUERY); return xDataRange->getData(); } - uno::Sequence< uno::Sequence< double > > vRows(nColCount); + uno::Sequence< uno::Sequence< double > > vRows(nRowCount); auto vCells(getCells()); auto pCurrentCell(vCells.begin()); for(auto& rRow : vRows) { - rRow = uno::Sequence<double>(nRowCount); + rRow = uno::Sequence<double>(nColCount); for(auto& rValue : rRow) { rValue = (*pCurrentCell)->getValue(); @@ -3733,24 +3733,25 @@ void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData const sal_uInt16 nColCount = getColumnCount(); if(!nRowCount || !nColCount) throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); + if(m_bFirstColumnAsLabel || m_bFirstRowAsLabel) + { + uno::Reference<chart::XChartDataArray> xDataRange(getCellRangeByPosition(m_bFirstColumnAsLabel ? 1 : 0, m_bFirstRowAsLabel ? 1 : 0, + nColCount-1, nRowCount-1), uno::UNO_QUERY); + return xDataRange->setData(rData); + } lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)); - const sal_uInt16 nRowStart = m_bFirstRowAsLabel ? 1 : 0; - if(rData.getLength() < nRowCount - nRowStart) - throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this)); - const uno::Sequence< double >* pRowArray = rData.getConstArray(); - for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; ++nRow) + if(rData.getLength() != nRowCount) + throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rData.getLength()), static_cast<cppu::OWeakObject*>(this)); + auto vCells(getCells()); + auto pCurrentCell(vCells.begin()); + for(const auto& rRow : rData) { - const uno::Sequence< double >& rColSeq = pRowArray[nRow - nRowStart]; - const sal_uInt16 nColStart = m_bFirstColumnAsLabel ? 1 : 0; - if(rColSeq.getLength() < nColCount - nColStart) - throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this)); - const double * pColArray = rColSeq.getConstArray(); - for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++) + if(rRow.getLength() != nColCount) + throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rRow.getLength()), static_cast<cppu::OWeakObject*>(this)); + for(const auto& rValue : rRow) { - uno::Reference<table::XCell> xCell = getCellByPosition(nCol, nRow); - if(!xCell.is()) - throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this)); - xCell->setValue(pColArray[nCol - nColStart]); + uno::Reference<table::XCell>(*pCurrentCell, uno::UNO_QUERY)->setValue(rValue); + ++pCurrentCell; } } } |