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

flatten and simplify

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