diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-03-30 18:17:40 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-03-30 23:20:26 +0200 |
commit | 77315c187af612e3534ad0926f205f0e83fb42fb (patch) | |
tree | 937865a0c475ea3ff2f4b25d3aad27021d2c84bc | |
parent | db123d181a48918dd85a90415d3557a78951c8bd (diff) |
SwXTextTable::setDataArray can reuse SwXCellRange too
Change-Id: Ia4aa4abcc6daa433004ab7f624f6b79c618a354d
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 66 |
1 files changed, 3 insertions, 63 deletions
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 6a043798481e..a1ef18e17a87 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2401,72 +2401,12 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray() return xAllRange->getDataArray(); } -void SAL_CALL SwXTextTable::setDataArray( - const uno::Sequence< uno::Sequence< uno::Any > >& rArray ) +void SAL_CALL SwXTextTable::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray) throw (uno::RuntimeException, std::exception) { - // see SwXTextTable::setData(...) also - SolarMutexGuard aGuard; - const sal_uInt16 nRowCount = getRowCount(); - const sal_uInt16 nColCount = getColumnCount(); - - SwFrmFmt* pFmt = GetFrmFmt(); - if(pFmt) - { - SwTable* pTable = SwTable::FindTable( pFmt ); - if(pTable->IsTblComplex()) - { - uno::RuntimeException aRuntime; - aRuntime.Message = "Table too complex"; - throw aRuntime; - } - - if(rArray.getLength() != nRowCount) - { - throw uno::RuntimeException(); - } - const uno::Sequence< uno::Any >* pRowArray = rArray.getConstArray(); - for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++) - { - const uno::Sequence< uno::Any >& rColSeq = pRowArray[nRow]; - if(rColSeq.getLength() != nColCount) - { - throw uno::RuntimeException(); - } - const uno::Any * pColArray = rColSeq.getConstArray(); - uno::Reference< table::XCell > xCellRef; - for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++) - { - SwXCell* pXCell = lcl_CreateXCell(pFmt, nCol, nRow); - //! keep (additional) reference to object to prevent implicit destruction - //! in following UNO calls (when object will get referenced) - xCellRef = pXCell; - SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0; - if(!pBox) - { - throw uno::RuntimeException(); - } - else - { - const uno::Any &rAny = pColArray[nCol]; - if (uno::TypeClass_STRING == rAny.getValueTypeClass()) - sw_setString( *pXCell, *static_cast<OUString const *>(rAny.getValue()) ); - else - { - double d = 0; - // #i20067# don't throw exception just do nothing if - // there is no value set - if( (rAny >>= d) ) - sw_setValue( *pXCell, d ); - else - sw_setString( *pXCell, OUString(), true ); - - } - } - } - } - } + uno::Reference<sheet::XCellRangeData> xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1), uno::UNO_QUERY); + return xAllRange->setDataArray(rArray); } uno::Sequence< uno::Sequence< double > > SwXTextTable::getData(void) |