summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-28 19:14:07 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-28 22:14:44 +0100
commit30b214b42385e7ef6024b35c0c18ad1cd6411f00 (patch)
tree7949fd6c6a67338440c7461d60fae64d9dab861b
parent10469041783dcfe98b04d15492cb058b6bd911a8 (diff)
simplify
Change-Id: I7161786371adf3b3e719b3e77abf145550db1c44
-rw-r--r--sw/source/core/unocore/unotbl.cxx60
1 files changed, 21 insertions, 39 deletions
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 9f0386ae2005..6de9600754e6 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -583,9 +583,9 @@ void SwRangeDescriptor::Normalize()
static SwXCell* lcl_CreateXCell(SwFrmFmt* pFmt, sal_Int32 nColumn, sal_Int32 nRow)
{
- SwXCell* pXCell = 0;
+ SwXCell* pXCell = nullptr;
const OUString sCellName = sw_GetCellName(nColumn, nRow);
- SwTable* pTable = SwTable::FindTable( pFmt );
+ SwTable* pTable = SwTable::FindTable(pFmt);
SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTblBox( sCellName ));
if(pBox)
{
@@ -2390,48 +2390,30 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray()
const sal_uInt16 nRowCount = getRowCount();
const sal_uInt16 nColCount = getColumnCount();
if(!nRowCount || !nColCount)
- {
- uno::RuntimeException aRuntime;
- aRuntime.Message = "Table too complex";
- throw aRuntime;
- }
- SwFrmFmt* pFmt = GetFrmFmt();
+ throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
+ SwFrmFmt* pFmt(GetFrmFmt());
uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
- if(pFmt)
+ if(!pFmt)
+ throw uno::RuntimeException();
+ sal_uInt16 nRow = 0;
+ for(auto& rRow : aRowSeq)
{
- uno::Sequence< uno::Any > * pRowArray = aRowSeq.getArray();
- for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
+ rRow = uno::Sequence< uno::Any >(nColCount);
+ sal_uInt16 nCol = 0;
+ for(auto& rCellAny : rRow)
{
- uno::Sequence< uno::Any > aColSeq(nColCount);
- uno::Any * pColArray = aColSeq.getArray();
- uno::Reference< table::XCell > xCellRef;
- for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++)
- {
- SwXCell* pXCell = lcl_CreateXCell(pFmt, nCol, nRow);
- //! keep (additional) reference to object to prevent implicit destruction
- //! in following UNO calls (when object will get referenced)
- xCellRef = pXCell;
- SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0;
- if(!pBox)
- {
- throw uno::RuntimeException();
- }
- else
- {
- // check if table box value item is set
- SwFrmFmt* pBoxFmt = pBox->GetFrmFmt();
- bool bIsNum = pBoxFmt->GetItemState( RES_BOXATR_VALUE, false ) == SfxItemState::SET;
- if(!bIsNum)
- pColArray[nCol] <<= lcl_getString(*pXCell);
- else
- pColArray[nCol] <<= sw_getValue(*pXCell);
- }
- }
- pRowArray[nRow] = aColSeq;
+ SwXCell* pXCell(lcl_CreateXCell(pFmt, nCol++, nRow));
+ uno::Reference<table::XCell> xCell = pXCell; // to prevent distruction in UNO calls
+ SwTableBox* pBox = pXCell ? pXCell->GetTblBox() : nullptr;
+ if(!pBox)
+ throw uno::RuntimeException();
+ // check if table box value item is set
+ SwFrmFmt* pBoxFmt(pBox->GetFrmFmt());
+ const bool bIsNum = pBoxFmt->GetItemState(RES_BOXATR_VALUE, false) == SfxItemState::SET;
+ rCellAny = bIsNum ? uno::makeAny(sw_getValue(*pXCell)) : uno::makeAny(lcl_getString(*pXCell));
}
+ ++nRow;
}
- else
- throw uno::RuntimeException();
return aRowSeq;
}