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

also refactor description setter

Change-Id: I69deac6d830f63aea94f3512ab4156217fbc7b27
üst bd00847f
...@@ -467,6 +467,7 @@ class SwXCellRange : public cppu::WeakImplHelper7 ...@@ -467,6 +467,7 @@ class SwXCellRange : public cppu::WeakImplHelper7
bool m_bFirstColumnAsLabel; bool m_bFirstColumnAsLabel;
std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32> getLabelCoordinates(bool bRow); std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32> getLabelCoordinates(bool bRow);
css::uno::Sequence<OUString> getLabelDescriptions(bool bRow); css::uno::Sequence<OUString> getLabelDescriptions(bool bRow);
void setLabelDescriptions(const css::uno::Sequence<OUString>& rDesc, bool bRow);
public: public:
SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt, SwRangeDescriptor& rDesc); SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt, SwRangeDescriptor& rDesc);
......
...@@ -4006,44 +4006,31 @@ uno::Sequence<OUString> SwXCellRange::getColumnDescriptions(void) ...@@ -4006,44 +4006,31 @@ uno::Sequence<OUString> SwXCellRange::getColumnDescriptions(void)
throw(uno::RuntimeException, std::exception) throw(uno::RuntimeException, std::exception)
{ return getLabelDescriptions(false); } { return getLabelDescriptions(false); }
void SwXCellRange::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc) void SwXCellRange::setLabelDescriptions(const uno::Sequence<OUString>& rDesc, bool bRow)
throw(uno::RuntimeException, std::exception)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)); lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
const sal_uInt16 nRowCount = getRowCount(); if(!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
if(!m_bFirstColumnAsLabel)
return; // if there are no labels we cannot set descriptions
const OUString* pArray = rRowDesc.getConstArray();
const sal_uInt16 nStart = m_bFirstColumnAsLabel ? 1 : 0;
if(!nRowCount || rRowDesc.getLength() + nStart < nRowCount)
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
for(sal_uInt16 i = nStart; i < nRowCount; i++)
{
uno::Reference<text::XText> xCell(getCellByPosition(0, i), uno::UNO_QUERY_THROW);
xCell->setString(pArray[i-nStart]);
}
}
void SwXCellRange::setColumnDescriptions(const uno::Sequence<OUString>& rColumnDesc)
throw(uno::RuntimeException, std::exception)
{
SolarMutexGuard aGuard;
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
const sal_uInt16 nColumnCount = getColumnCount();
if(!m_bFirstRowAsLabel)
return; // if there are no labels we cannot set descriptions return; // if there are no labels we cannot set descriptions
const sal_uInt16 nStart = m_bFirstRowAsLabel ? 1 : 0; sal_uInt32 nLeft, nTop, nRight, nBottom;
if(!nColumnCount || rColumnDesc.getLength() + nStart < nColumnCount) std::tie(nLeft, nTop, nRight, nBottom) = getLabelCoordinates(bRow);
throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this)); if(!nRight && !nBottom)
const OUString* pArray = rColumnDesc.getConstArray(); throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
for(sal_uInt16 i = nStart; i < nColumnCount; i++) auto xLabelRange(getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
{ auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->getCells());
uno::Reference<text::XText> xCell(getCellByPosition(i, 0), uno::UNO_QUERY_THROW); if(rDesc.getLength() != vCells.size())
xCell->setString(pArray[i-nStart]); throw uno::RuntimeException("Too few or too many descriptions", static_cast<cppu::OWeakObject*>(this));
} auto pDescIterator(rDesc.begin());
for(auto xCell : vCells)
uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->setString(*pDescIterator++);
} }
void SwXCellRange::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc)
throw(uno::RuntimeException, std::exception)
{ setLabelDescriptions(rRowDesc, true); }
void SwXCellRange::setColumnDescriptions(const uno::Sequence<OUString>& rColumnDesc)
throw(uno::RuntimeException, std::exception)
{ setLabelDescriptions(rColumnDesc, false); }
void SAL_CALL SwXCellRange::addChartDataChangeEventListener( void SAL_CALL SwXCellRange::addChartDataChangeEventListener(
const uno::Reference<chart::XChartDataChangeEventListener> & xListener) const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
......
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