diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-04-11 01:18:24 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-04-13 17:21:28 +0200 |
commit | 27972b53a5695ffba720d377d15b0bde60dd79f9 (patch) | |
tree | 9b46acab6338656f487e182fd0df7d7e57a1dc89 /sw | |
parent | ff1c479dba6210a885a4bd561a2f4c29ec0ee99e (diff) |
simplify
Change-Id: I18670621a218f77b7996c3b7418fde4c4a230059
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 74 |
1 files changed, 22 insertions, 52 deletions
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index eb5a0f883078..f8a3847261c6 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3717,66 +3717,36 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray() } ///@see SwXCellRange::setData -void SAL_CALL SwXCellRange::setDataArray( - const uno::Sequence< uno::Sequence< uno::Any > >& rArray ) - throw (uno::RuntimeException, std::exception) +void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray) throw (uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; const sal_uInt16 nRowCount = getRowCount(); const sal_uInt16 nColCount = getColumnCount(); if(!nRowCount || !nColCount) - { - uno::RuntimeException aRuntime; - aRuntime.Message = "Table too complex"; - throw aRuntime; - } + throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); SwFrmFmt* pFmt = GetFrmFmt(); - if(pFmt ) + if(!pFmt) + return; + if(rArray.getLength() != nRowCount) + throw uno::RuntimeException("Row count mismatch", static_cast<cppu::OWeakObject*>(this)); + auto vCells(getCells()); + auto pCurrentCell(vCells.begin()); + for(const auto& rColSeq : rArray) { - if(rArray.getLength() != nRowCount) + if(rColSeq.getLength() != nColCount) + throw uno::RuntimeException("Column count mismatch", static_cast<cppu::OWeakObject*>(this)); + for(const auto& aValue : rColSeq) { - 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, - aRgDesc.nLeft + nCol, - aRgDesc.nTop + 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 ); - } - } - } + auto pCell(static_cast<SwXCell*>(pCurrentCell->get())); + if(!pCell || !pCell->GetTblBox()) + throw uno::RuntimeException("Box for cell missing", static_cast<cppu::OWeakObject*>(this)); + if(aValue.isExtractableTo(cppu::UnoType<OUString>::get())) + sw_setString(*pCell, aValue.get<OUString>()); + else if(aValue.isExtractableTo(cppu::UnoType<double>::get())) + sw_setValue(*pCell, aValue.get<double>()); + else + sw_setString(*pCell, OUString(), true); + ++pCurrentCell; } } } |