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

SwXTextTable::setDataArray can reuse SwXCellRange too

Change-Id: Ia4aa4abcc6daa433004ab7f624f6b79c618a354d
üst db123d18
...@@ -2401,72 +2401,12 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray() ...@@ -2401,72 +2401,12 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray()
return xAllRange->getDataArray(); return xAllRange->getDataArray();
} }
void SAL_CALL SwXTextTable::setDataArray( void SAL_CALL SwXTextTable::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray)
const uno::Sequence< uno::Sequence< uno::Any > >& rArray )
throw (uno::RuntimeException, std::exception) throw (uno::RuntimeException, std::exception)
{ {
// see SwXTextTable::setData(...) also
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
const sal_uInt16 nRowCount = getRowCount(); uno::Reference<sheet::XCellRangeData> xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1), uno::UNO_QUERY);
const sal_uInt16 nColCount = getColumnCount(); return xAllRange->setDataArray(rArray);
SwFrmFmt* pFmt = GetFrmFmt();
if(pFmt)
{
SwTable* pTable = SwTable::FindTable( pFmt );
if(pTable->IsTblComplex())
{
uno::RuntimeException aRuntime;
aRuntime.Message = "Table too complex";
throw aRuntime;
}
if(rArray.getLength() != nRowCount)
{
throw uno::RuntimeException();
}
const uno::Sequence< uno::Any >* pRowArray = rArray.getConstArray();
for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++)
{
const uno::Sequence< uno::Any >& rColSeq = pRowArray[nRow];
if(rColSeq.getLength() != nColCount)
{
throw uno::RuntimeException();
}
const uno::Any * pColArray = rColSeq.getConstArray();
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
{
const uno::Any &rAny = pColArray[nCol];
if (uno::TypeClass_STRING == rAny.getValueTypeClass())
sw_setString( *pXCell, *static_cast<OUString const *>(rAny.getValue()) );
else
{
double d = 0;
// #i20067# don't throw exception just do nothing if
// there is no value set
if( (rAny >>= d) )
sw_setValue( *pXCell, d );
else
sw_setString( *pXCell, OUString(), true );
}
}
}
}
}
} }
uno::Sequence< uno::Sequence< double > > SwXTextTable::getData(void) uno::Sequence< uno::Sequence< double > > SwXTextTable::getData(void)
......
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