Kaydet (Commit) ea35a682 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

use getCells()

Change-Id: Ib3e115b7b96d0536db6917e84cfac7816176b296
üst b845d236
...@@ -3674,13 +3674,13 @@ void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno ...@@ -3674,13 +3674,13 @@ void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno
if(!pFmt) if(!pFmt)
return; return;
if(rArray.getLength() != nRowCount) 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 vCells(getCells());
auto pCurrentCell(vCells.begin()); auto pCurrentCell(vCells.begin());
for(const auto& rColSeq : rArray) for(const auto& rColSeq : rArray)
{ {
if(rColSeq.getLength() != nColCount) 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) for(const auto& aValue : rColSeq)
{ {
auto pCell(static_cast<SwXCell*>(pCurrentCell->get())); auto pCell(static_cast<SwXCell*>(pCurrentCell->get()));
...@@ -3706,16 +3706,16 @@ uno::Sequence< uno::Sequence< double > > SwXCellRange::getData(void) throw( uno: ...@@ -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)); throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
if(m_bFirstColumnAsLabel || m_bFirstRowAsLabel) if(m_bFirstColumnAsLabel || m_bFirstRowAsLabel)
{ {
uno::Reference<chart::XChartDataArray> xDataRange(getCellRangeByPosition(m_bFirstRowAsLabel ? 1 : 0, m_bFirstColumnAsLabel ? 1 : 0, uno::Reference<chart::XChartDataArray> xDataRange(getCellRangeByPosition(m_bFirstColumnAsLabel ? 1 : 0, m_bFirstRowAsLabel ? 1 : 0,
nRowCount, nColCount), uno::UNO_QUERY); nColCount-1, nRowCount-1), uno::UNO_QUERY);
return xDataRange->getData(); return xDataRange->getData();
} }
uno::Sequence< uno::Sequence< double > > vRows(nColCount); uno::Sequence< uno::Sequence< double > > vRows(nRowCount);
auto vCells(getCells()); auto vCells(getCells());
auto pCurrentCell(vCells.begin()); auto pCurrentCell(vCells.begin());
for(auto& rRow : vRows) for(auto& rRow : vRows)
{ {
rRow = uno::Sequence<double>(nRowCount); rRow = uno::Sequence<double>(nColCount);
for(auto& rValue : rRow) for(auto& rValue : rRow)
{ {
rValue = (*pCurrentCell)->getValue(); rValue = (*pCurrentCell)->getValue();
...@@ -3733,24 +3733,25 @@ void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData ...@@ -3733,24 +3733,25 @@ void SwXCellRange::setData(const uno::Sequence< uno::Sequence< double > >& rData
const sal_uInt16 nColCount = getColumnCount(); const sal_uInt16 nColCount = getColumnCount();
if(!nRowCount || !nColCount) if(!nRowCount || !nColCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); 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)); lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
const sal_uInt16 nRowStart = m_bFirstRowAsLabel ? 1 : 0; if(rData.getLength() != nRowCount)
if(rData.getLength() < nRowCount - nRowStart) throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rData.getLength()), static_cast<cppu::OWeakObject*>(this));
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this)); auto vCells(getCells());
const uno::Sequence< double >* pRowArray = rData.getConstArray(); auto pCurrentCell(vCells.begin());
for(sal_uInt16 nRow = nRowStart; nRow < nRowCount; ++nRow) for(const auto& rRow : rData)
{ {
const uno::Sequence< double >& rColSeq = pRowArray[nRow - nRowStart]; if(rRow.getLength() != nColCount)
const sal_uInt16 nColStart = m_bFirstColumnAsLabel ? 1 : 0; throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rRow.getLength()), static_cast<cppu::OWeakObject*>(this));
if(rColSeq.getLength() < nColCount - nColStart) for(const auto& rValue : rRow)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
const double * pColArray = rColSeq.getConstArray();
for(sal_uInt16 nCol = nColStart; nCol < nColCount; nCol++)
{ {
uno::Reference<table::XCell> xCell = getCellByPosition(nCol, nRow); uno::Reference<table::XCell>(*pCurrentCell, uno::UNO_QUERY)->setValue(rValue);
if(!xCell.is()) ++pCurrentCell;
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
xCell->setValue(pColArray[nCol - nColStart]);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment