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

flatten and simplify

Change-Id: Ie2500d115d3fd856481345430839507c814c1bac
üst 326177f4
...@@ -4604,16 +4604,14 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) ...@@ -4604,16 +4604,14 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwFrmFmt* pFrmFmt = GetFrmFmt(); SwFrmFmt* pFrmFmt = GetFrmFmt();
if(!pFrmFmt || nIndex < 0 || nCount <=0 ) if(!pFrmFmt || nIndex < 0 || nCount <=0 )
throw uno::RuntimeException(); throw uno::RuntimeException();
else
{
bool bSuccess = false; bool bSuccess = false;
SwTable* pTable = SwTable::FindTable( pFrmFmt ); SwTable* pTable = SwTable::FindTable( pFrmFmt );
if(!pTable->IsTblComplex()) if(pTable->IsTblComplex())
{ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
OUString sTLName = sw_GetCellName(0, nIndex); OUString sTLName = sw_GetCellName(0, nIndex);
const SwTableBox* pTLBox = pTable->GetTblBox( sTLName ); const SwTableBox* pTLBox = pTable->GetTblBox(sTLName);
if(pTLBox) if(!pTLBox)
{ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
{ {
// invalidate all actions // invalidate all actions
UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc()); UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
...@@ -4622,38 +4620,26 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) ...@@ -4622,38 +4620,26 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwPosition aPos(*pSttNd); SwPosition aPos(*pSttNd);
// set cursor to the upper-left cell of the range // set cursor to the upper-left cell of the range
SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true); SwUnoCrsr* pUnoCrsr = pFrmFmt->GetDoc()->CreateUnoCrsr(aPos, true);
pUnoCrsr->Move( fnMoveForward, fnGoNode ); pUnoCrsr->Move(fnMoveForward, fnGoNode);
pUnoCrsr->SetRemainInSection( false ); pUnoCrsr->SetRemainInSection( false );
const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1); const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1);
const SwTableBox* pBLBox = pTable->GetTblBox( sBLName ); const SwTableBox* pBLBox = pTable->GetTblBox( sBLName );
if(pBLBox) if(!pBLBox)
{ throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
pUnoCrsr->SetMark(); pUnoCrsr->SetMark();
pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd(); pUnoCrsr->GetPoint()->nNode = *pBLBox->GetSttNd();
pUnoCrsr->Move( fnMoveForward, fnGoNode ); pUnoCrsr->Move(fnMoveForward, fnGoNode);
SwUnoTableCrsr* pCrsr = SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr);
pCrsr->MakeBoxSels(); pCrsr->MakeBoxSels();
{ // these braces are important { // these braces are important
UnoActionContext aAction(pFrmFmt->GetDoc()); UnoActionContext aAction(pFrmFmt->GetDoc());
pFrmFmt->GetDoc()->DeleteRow(*pUnoCrsr); pFrmFmt->GetDoc()->DeleteRow(*pUnoCrsr);
delete pUnoCrsr; delete pUnoCrsr;
bSuccess = true;
} }
{ {
// invalidate all actions // invalidate all actions
UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc()); UnoActionRemoveContext aRemoveContext(pFrmFmt->GetDoc());
} }
}
}
}
if(!bSuccess)
{
uno::RuntimeException aExcept;
aExcept.Message = "Illegal arguments";
throw aExcept;
}
}
} }
void SwXTableRows::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) void SwXTableRows::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
......
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