diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-03-29 00:51:54 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-03-30 23:17:29 +0200 |
commit | 78ccfb18662af879b9ed12451efb097c4dda3118 (patch) | |
tree | 2c6b9adec5e3bee31bd86daea6863ab80989bc77 /sw/source/core/unocore/unotbl.cxx | |
parent | 326177f4c4f3ae07fef9b66328abcea91ee18358 (diff) |
flatten and simplify
Change-Id: Ie2500d115d3fd856481345430839507c814c1bac
Diffstat (limited to 'sw/source/core/unocore/unotbl.cxx')
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 82 |
1 files changed, 34 insertions, 48 deletions
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index fb3a4fd580c2..fbd5f3c80526 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -4604,55 +4604,41 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) SwFrmFmt* pFrmFmt = GetFrmFmt(); if(!pFrmFmt || nIndex < 0 || nCount <=0 ) throw uno::RuntimeException(); - else + bool bSuccess = false; + SwTable* pTable = SwTable::FindTable( pFrmFmt ); + if(pTable->IsTblComplex()) + throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); + OUString sTLName = sw_GetCellName(0, nIndex); + const SwTableBox* pTLBox = pTable->GetTblBox(sTLName); + if(!pTLBox) + throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this)); { - bool bSuccess = false; - SwTable* pTable = SwTable::FindTable( pFrmFmt ); - if(!pTable->IsTblComplex()) - { - OUString sTLName = sw_GetCellName(0, nIndex); - const SwTableBox* pTLBox = pTable->GetTblBox( sTLName ); - if(pTLBox) - { - { - // invalidate all actions - UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc()); - } - const SwStartNode* pSttNd = pTLBox->GetSttNd(); - SwPosition aPos(*pSttNd); - // set cursor to the upper-left cell of the range - SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); - pUnoCrsr->SetRemainInSection( false ); - const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1); - const SwTableBox* pBLBox = pTable->GetTblBox( sBLName ); - if(pBLBox) - { - pUnoCrsr->SetMark(); - pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd(); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = - dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); - pCrsr->MakeBoxSels(); - { // these braces are important - UnoActionContext aAction(pFrmFmt->GetDoc()); - pFrmFmt->GetDoc()->DeleteRow(*pUnoCrsr); - delete pUnoCrsr; - bSuccess = true; - } - { - // invalidate all actions - UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc()); - } - } - } - } - if(!bSuccess) - { - uno::RuntimeException aExcept; - aExcept.Message = "Illegal arguments"; - throw aExcept; - } + // invalidate all actions + UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc()); + } + const SwStartNode* pSttNd = pTLBox->GetSttNd(); + SwPosition aPos(*pSttNd); + // set cursor to the upper-left cell of the range + SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true); + pUnoCrsr->Move(fnMoveForward, fnGoNode); + pUnoCrsr->SetRemainInSection( false ); + const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1); + const SwTableBox* pBLBox = pTable->GetTblBox( sBLName ); + if(!pBLBox) + throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this)); + pUnoCrsr->SetMark(); + pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd(); + pUnoCrsr->Move(fnMoveForward, fnGoNode); + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); + pCrsr->MakeBoxSels(); + { // these braces are important + UnoActionContext aAction(pFrmFmt->GetDoc()); + pFrmFmt->GetDoc()->DeleteRow(*pUnoCrsr); + delete pUnoCrsr; + } + { + // invalidate all actions + UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc()); } } |