diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-03-30 01:26:21 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-03-30 23:20:10 +0200 |
commit | f86d0413f7cedf096b285c2eb6698653dd99c21e (patch) | |
tree | b9af9a3991c579d52cef148c669b39890ea4ab4f /sw/source | |
parent | 439ca5309f7e7659802f7fef44c8690fa099ac22 (diff) |
SwXCellRange:: and SwXTextTable::getDataArray() do the same
Change-Id: Ied6712729be7784ec72b1ee5c548527201b406f7
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 91 |
1 files changed, 23 insertions, 68 deletions
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 95fd5e9b0b20..c943da8f90ac 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2396,37 +2396,11 @@ uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByName(const OUStrin uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray() throw (uno::RuntimeException, std::exception) { - // see SwXTextTable::getData(...) also - SolarMutexGuard aGuard; - const sal_uInt16 nRowCount = getRowCount(); - const sal_uInt16 nColCount = getColumnCount(); - if(!nRowCount || !nColCount) - throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); - SwFrmFmt* pFmt(GetFrmFmt()); - uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount); - if(!pFmt) - throw uno::RuntimeException(); - sal_uInt16 nRow = 0; - for(auto& rRow : aRowSeq) - { - rRow = uno::Sequence< uno::Any >(nColCount); - sal_uInt16 nCol = 0; - for(auto& rCellAny : rRow) - { - 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; - } - return aRowSeq; + //auto xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1)); + //return static_cast<SwXCellRange*>(xAllRange.get())->getDataArray(); + uno::Reference<sheet::XCellRangeData> xAllRange(getCellRangeByPosition(0, 0, getColumnCount()-1, getRowCount()-1), uno::UNO_QUERY); + return xAllRange->getDataArray(); } void SAL_CALL SwXTextTable::setDataArray( @@ -4037,49 +4011,30 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXCellRange::getDataArray() SolarMutexGuard aGuard; const sal_uInt16 nRowCount = getRowCount(); const sal_uInt16 nColCount = getColumnCount(); - if(!nRowCount || !nColCount) - { - uno::RuntimeException aRuntime; - aRuntime.Message = "Table too complex"; - throw aRuntime; - } + throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); + SwFrmFmt* pFmt(GetFrmFmt()); uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount); - SwFrmFmt* pFmt = GetFrmFmt(); - if(pFmt) + if(!pFmt) + throw uno::RuntimeException(); + sal_uInt16 nRow = 0; + for(auto& rRow : aRowSeq) { - uno::Sequence< uno::Any >* pRowArray = aRowSeq.getArray(); - uno::Reference< table::XCell > xCellRef; - 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(); - for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++) - { - SwXCell * pXCell = lcl_CreateXCell(pFmt, - aRgDesc.nLeft + nCol, - aRgDesc.nTop + 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; } return aRowSeq; } |