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

flatten and simplify

Change-Id: I85d5715d6e4535463524dbc8af452655731acd54
üst 9bab5e14
...@@ -4761,49 +4761,39 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount) ...@@ -4761,49 +4761,39 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwFrmFmt* pFrmFmt = GetFrmFmt(); SwFrmFmt* pFrmFmt = GetFrmFmt();
if(!pFrmFmt) if(!pFrmFmt)
throw uno::RuntimeException(); throw uno::RuntimeException();
else SwTable* pTable = SwTable::FindTable( pFrmFmt );
if(pTable->IsTblComplex())
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
SwTableLines& rLines = pTable->GetTabLines();
SwTableLine* pLine = rLines.front();
const size_t nColCount = pLine->GetTabBoxes().size();
if (nCount <= 0 || !(0 <= nIndex && static_cast<size_t>(nIndex) <= nColCount))
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
const OUString sTLName = sw_GetCellName(nIndex, 0);
const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
bool bAppend = false;
if(!pTLBox)
{ {
SwTable* pTable = SwTable::FindTable( pFrmFmt ); bAppend = true;
if(!pTable->IsTblComplex()) // to append at the end the cursor must be in the last line
{ SwTableBoxes& rBoxes = pLine->GetTabBoxes();
SwTableLines& rLines = pTable->GetTabLines(); pTLBox = rBoxes.back();
SwTableLine* pLine = rLines.front(); }
const size_t nColCount = pLine->GetTabBoxes().size(); if(!pTLBox)
if (nCount <= 0 || !(0 <= nIndex && static_cast<size_t>(nIndex) <= nColCount)) throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
{ const SwStartNode* pSttNd = pTLBox->GetSttNd();
uno::RuntimeException aExcept; SwPosition aPos(*pSttNd);
aExcept.Message = "Illegal arguments"; UnoActionContext aAction(pFrmFmt->GetDoc());
throw aExcept; SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
} pUnoCrsr->Move(fnMoveForward, fnGoNode);
const OUString sTLName = sw_GetCellName(nIndex, 0);
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
SwTableBoxes& rBoxes = pLine->GetTabBoxes();
pTLBox = rBoxes.back();
}
if(pTLBox)
{
const SwStartNode* pSttNd = pTLBox->GetSttNd();
SwPosition aPos(*pSttNd);
UnoActionContext aAction(pFrmFmt->GetDoc());
SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
pUnoCrsr->Move( fnMoveForward, fnGoNode );
{
// remove actions
UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
}
pFrmFmt->GetDoc()->InsertCol(*pUnoCrsr, (sal_uInt16)nCount, bAppend); {
delete pUnoCrsr; // remove actions
} UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc());
}
} }
pFrmFmt->GetDoc()->InsertCol(*pUnoCrsr, (sal_uInt16)nCount, bAppend);
delete pUnoCrsr;
} }
///@see SwXTableRows::removeByIndex (TODO: seems to be copy and paste programming here) ///@see SwXTableRows::removeByIndex (TODO: seems to be copy and paste programming here)
......
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