summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-29 15:12:39 +0200
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-30 23:20:05 +0200
commit374d2bcf67dac2bf7b41ac2d96eb666c627499ef (patch)
treec5b9708572e0c13bfd0d88d86ac5f0342cf1c05d /sw
parent696f79a80d93a53b8c05bfef71865e05b0bc03e9 (diff)
use helper function for precond check
Change-Id: I6b3c9d50229265e26c1dc8da9194164c18c1687a
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/unocore/unotbl.cxx22
1 files changed, 10 insertions, 12 deletions
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index b81d7343ec20..4f72f9268727 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -121,6 +121,12 @@ namespace
throw uno::RuntimeException("Lost connection to core objects", pObject);
return pFmt;
}
+ SwTable* lcl_EnsureTableNotComplex(SwTable* pTable, cppu::OWeakObject* pObject)
+ {
+ if(pTable->IsTblComplex())
+ throw uno::RuntimeException("Table too complex", pObject);
+ return pTable;
+ }
}
#define UNO_TABLE_COLUMN_SUM 10000
@@ -4446,9 +4452,7 @@ void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
if (nCount == 0)
return;
SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
- SwTable* pTable = SwTable::FindTable(pFrmFmt);
- if(pTable->IsTblComplex())
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrmFmt), 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));
@@ -4490,9 +4494,7 @@ void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
if(nIndex < 0 || nCount <=0 )
throw uno::RuntimeException();
bool bSuccess = false;
- SwTable* pTable = SwTable::FindTable( pFrmFmt );
- if(pTable->IsTblComplex())
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrmFmt), static_cast<cppu::OWeakObject*>(this));
OUString sTLName = sw_GetCellName(0, nIndex);
const SwTableBox* pTLBox = pTable->GetTblBox(sTLName);
if(!pTLBox)
@@ -4591,9 +4593,7 @@ void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
if (nCount == 0)
return;
SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
- SwTable* pTable = SwTable::FindTable( pFrmFmt );
- if(pTable->IsTblComplex())
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrmFmt), static_cast<cppu::OWeakObject*>(this));
SwTableLines& rLines = pTable->GetTabLines();
SwTableLine* pLine = rLines.front();
const size_t nColCount = pLine->GetTabBoxes().size();
@@ -4636,9 +4636,7 @@ void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
SwFrmFmt* pFrmFmt(lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)));
if(nIndex < 0 || nCount <=0 )
throw uno::RuntimeException();
- SwTable* pTable = SwTable::FindTable(pFrmFmt);
- if(pTable->IsTblComplex())
- throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrmFmt), static_cast<cppu::OWeakObject*>(this));
const OUString sTLName = sw_GetCellName(nIndex, 0);
const SwTableBox* pTLBox = pTable->GetTblBox( sTLName );
if(!pTLBox)