summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-29 00:56:08 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-30 23:17:29 +0200
commitfe447d2e1b6e1b0fa5d3d12bf5e8b3dab5733da0 (patch)
tree02be933b810a7c8de0756e28a9c4d0c387543e23 /sw
parent78ccfb18662af879b9ed12451efb097c4dda3118 (diff)
flatten and simplify
Change-Id: I2ec511a662b8109399cc2d836108fe8ceb12a1b8
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/unocore/unotbl.cxx72
1 files changed, 30 insertions, 42 deletions
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index fbd5f3c80526..09f90c6d188f 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -4549,50 +4549,38 @@ void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwFrmFmt* pFrmFmt = GetFrmFmt();
if(!pFrmFmt)
throw uno::RuntimeException();
- else
+ SwTable* pTable = SwTable::FindTable(pFrmFmt);
+ if(pTable->IsTblComplex())
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ const size_t nRowCount = pTable->GetTabLines().size();
+ if (nCount <= 0 || !(0 <= nIndex && static_cast<size_t>(nIndex) <= nRowCount))
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ const OUString sTLName = sw_GetCellName(0, nIndex);
+ const SwTableBox* pTLBox = pTable->GetTblBox(sTLName);
+ bool bAppend = false;
+ if(!pTLBox)
{
- SwTable* pTable = SwTable::FindTable( pFrmFmt );
- if(!pTable->IsTblComplex())
- {
- const size_t nRowCount = pTable->GetTabLines().size();
- if (nCount <= 0 || !(0 <= nIndex && static_cast<size_t>(nIndex) <= nRowCount))
- {
- uno::RuntimeException aExcept;
- aExcept.Message = "Illegal arguments";
- throw aExcept;
- }
-
- const OUString sTLName = sw_GetCellName(0, nIndex);
- const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
- bool bAppend = false;
- if(!pTLBox)
- {
- bAppend = true;
- // to append at the end the cursor must be in the last line
- SwTableLines& rLines = pTable->GetTabLines();
- SwTableLine* pLine = rLines.back();
- SwTableBoxes& rBoxes = pLine->GetTabBoxes();
- pTLBox = rBoxes.front();
- }
- if(pTLBox)
- {
- const SwStartNode* pSttNd = pTLBox->GetSttNd();
- SwPosition aPos(*pSttNd);
- // set cursor to the upper-left cell of the range
- UnoActionContext aAction(pFrmFmt->GetDoc());
- SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
- pUnoCrsr->Move( fnMoveForward, fnGoNode );
-
- {
- // remove actions
- UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
- }
-
- pFrmFmt->GetDoc()->InsertRow(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
- delete pUnoCrsr;
- }
- }
+ bAppend = true;
+ // to append at the end the cursor must be in the last line
+ SwTableLines& rLines = pTable->GetTabLines();
+ SwTableLine* pLine = rLines.back();
+ SwTableBoxes& rBoxes = pLine->GetTabBoxes();
+ pTLBox = rBoxes.front();
+ }
+ if(!pTLBox)
+ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
+ const SwStartNode* pSttNd = pTLBox->GetSttNd();
+ SwPosition aPos(*pSttNd);
+ // set cursor to the upper-left cell of the range
+ UnoActionContext aAction(pFrmFmt->GetDoc());
+ SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
+ pUnoCrsr->Move( fnMoveForward, fnGoNode );
+ {
+ // remove actions
+ UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
}
+ pFrmFmt->GetDoc()->InsertRow(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
+ delete pUnoCrsr;
}
void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)