summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-31 03:25:08 +0200
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-04-01 13:59:33 +0200
commit849bf23a4996a302a08b93472c0bbd5d905f7baf (patch)
tree160e40635181ae00f2e097449bdf0a797170d1d7 /sw
parent95635695539f3c2068c5dc16a430562373437ce2 (diff)
create generic getCells() function
Change-Id: I36f0b7113e22b801295eb704b8f5f9df4536eddc
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/unotbl.hxx1
-rw-r--r--sw/source/core/unocore/unotbl.cxx32
2 files changed, 24 insertions, 9 deletions
diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index bc81c9469dbf..9345ffbc8d0f 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -469,6 +469,7 @@ public:
SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt, SwRangeDescriptor& rDesc);
void SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
{ m_bFirstRowAsLabel = bFirstRowAsLabel, m_bFirstColumnAsLabel = bFirstColumnAsLabel; }
+ std::vector< css::uno::Reference< css::table::XCell > > getCells();
virtual ~SwXCellRange();
TYPEINFO_OVERRIDE();
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index e3253e3701f0..80e804f63b74 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -20,6 +20,7 @@
#include <list>
#include <utility>
#include <vector>
+#include <algorithm>
#include <svx/svxids.hrc>
#include <editeng/memberids.hrc>
@@ -3324,6 +3325,19 @@ SwXCellRange::SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt,
aRgDesc.Normalize();
}
+std::vector< uno::Reference< table::XCell > > SwXCellRange::getCells()
+{
+ SwFrmFmt* const pFmt = GetFrmFmt();
+ const size_t nRowCount(getRowCount());
+ const size_t nColCount(getColumnCount());
+ std::vector< uno::Reference< table::XCell > > vResult;
+ vResult.reserve(nRowCount*nColCount);
+ for(sal_uInt16 nRow = 0; nRow < nRowCount; ++nRow)
+ for(sal_uInt16 nCol = 0; nCol < nColCount; ++nCol)
+ vResult.push_back(uno::Reference< table::XCell >(lcl_CreateXCell(pFmt, aRgDesc.nLeft + nCol, aRgDesc.nTop + nRow)));
+ return vResult;
+}
+
SwXCellRange::~SwXCellRange()
{
SolarMutexGuard aGuard;
@@ -3957,18 +3971,18 @@ uno::Sequence<OUString> SwXCellRange::getRowDescriptions(void)
const sal_uInt16 nRowCount = getRowCount();
if(!nRowCount)
throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
- uno::Sequence<OUString> aRet(m_bFirstColumnAsLabel ? nRowCount - 1 : nRowCount);
lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this));
if(!m_bFirstColumnAsLabel)
return {}; // without labels we have no descriptions
- OUString* pArray = aRet.getArray();
- const sal_uInt16 nStart = m_bFirstRowAsLabel ? 1 : 0;
- for(sal_uInt16 i = nStart; i < nRowCount; i++)
- {
- const uno::Reference<text::XText> xCell(getCellByPosition(0, i), uno::UNO_QUERY_THROW);
- pArray[i - nStart] = xCell->getString();
- }
- return aRet;
+ uno::Reference<chart::XChartDataArray> xRowLabelRange(getCellRangeByPosition(0, m_bFirstRowAsLabel ? 1 : 0, 0, nRowCount-1), uno::UNO_QUERY);
+ auto vCells(static_cast<SwXCellRange*>(xRowLabelRange.get())->getCells());
+ uno::Sequence<OUString> vResult(vCells.size());
+ //size_t i = 0;
+ //for(auto& xCell : vCells)
+ // vResult[i++] = uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->getString();
+ std::transform(vCells.begin(), vCells.end(), vResult.begin(),
+ [](uno::Reference<table::XCell> xCell) -> OUString { return uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->getString(); });
+ return vResult;
}
uno::Sequence<OUString> SwXCellRange::getColumnDescriptions(void)
throw(uno::RuntimeException, std::exception)