[Libreoffice-commits] core.git: sc/inc sc/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Wed May 3 21:17:44 UTC 2017
sc/inc/PivotTableDataProvider.hxx | 7 +-
sc/source/ui/unoobj/PivotTableDataProvider.cxx | 68 +++++++++++--------------
2 files changed, 35 insertions(+), 40 deletions(-)
New commits:
commit 089c8a6edb3425a18632b855e0ae74875f236dba
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Mon May 1 22:06:35 2017 +0200
simplify filling of categories in pivot table data provider
Change-Id: I0940126fcb96d36f168a1c995504b6e9ce92564a
Reviewed-on: https://gerrit.libreoffice.org/37209
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/sc/inc/PivotTableDataProvider.hxx b/sc/inc/PivotTableDataProvider.hxx
index f572cbdf797d..b1924753ece3 100644
--- a/sc/inc/PivotTableDataProvider.hxx
+++ b/sc/inc/PivotTableDataProvider.hxx
@@ -142,19 +142,18 @@ private:
css::uno::Reference<css::chart2::data::XDataSource>
createValuesDataSource();
+
css::uno::Reference<css::chart2::data::XDataSource>
createCategoriesDataSource(bool bOrientationIsColumn);
css::uno::Reference<css::chart2::data::XLabeledDataSequence> newLabeledDataSequence();
- void setLabeledDataSequenceValues(css::uno::Reference<css::chart2::data::XLabeledDataSequence> & xResult,
- OUString const & sRoleValues, OUString const & sIdValues,
- std::vector<ValueAndFormat> const & rValues);
-
css::uno::Reference<css::chart2::data::XDataSequence> assignLabelsToDataSequence(size_t nIndex);
css::uno::Reference<css::chart2::data::XDataSequence> assignValuesToDataSequence(size_t nIndex);
+ css::uno::Reference<css::chart2::data::XDataSequence> assignFirstCategoriesToDataSequence();
+
void collectPivotTableData();
ScDocument* m_pDocument;
diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
index fee34e6f9cc8..34141bf1675a 100644
--- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx
+++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx
@@ -249,16 +249,6 @@ uno::Reference<chart2::data::XLabeledDataSequence>
return xResult;
}
-void PivotTableDataProvider::setLabeledDataSequenceValues(uno::Reference<chart2::data::XLabeledDataSequence> & xResult,
- OUString const & sRoleValues, OUString const & sIdValues,
- std::vector<ValueAndFormat> const & rValues)
-{
- std::unique_ptr<PivotTableDataSequence> pSequence(
- new PivotTableDataSequence(m_pDocument, m_sPivotTableName, sIdValues, rValues));
- pSequence->setRole(sRoleValues);
- xResult->setValues(uno::Reference<chart2::data::XDataSequence>(pSequence.release()));
-}
-
uno::Reference<chart2::data::XDataSource>
PivotTableDataProvider::createCategoriesDataSource(bool bOrientationIsColumn)
{
@@ -274,7 +264,12 @@ PivotTableDataProvider::createCategoriesDataSource(bool bOrientationIsColumn)
for (std::vector<ValueAndFormat> const & rCategories : rCategoriesVector)
{
uno::Reference<chart2::data::XLabeledDataSequence> xResult = newLabeledDataSequence();
- setLabeledDataSequenceValues(xResult, "categories", lcl_identifierForCategories(), rCategories);
+ std::unique_ptr<PivotTableDataSequence> pSequence;
+ pSequence.reset(new PivotTableDataSequence(m_pDocument, m_sPivotTableName,
+ lcl_identifierForCategories(), rCategories));
+ pSequence->setRole("categories");
+ xResult->setValues(uno::Reference<chart2::data::XDataSequence>(pSequence.release()));
+
aLabeledSequences.push_back(xResult);
}
@@ -620,13 +615,33 @@ PivotTableDataProvider::assignLabelsToDataSequence(size_t nIndex)
std::vector<ValueAndFormat> aLabelVector { ValueAndFormat(aLabel) };
- std::unique_ptr<PivotTableDataSequence> pSequence(new PivotTableDataSequence(m_pDocument, m_sPivotTableName,
- sLabelID, aLabelVector));
+ std::unique_ptr<PivotTableDataSequence> pSequence;
+ pSequence.reset(new PivotTableDataSequence(m_pDocument, m_sPivotTableName,
+ sLabelID, aLabelVector));
pSequence->setRole("values-y");
xDataSequence.set(pSequence.release());
return xDataSequence;
}
+css::uno::Reference<css::chart2::data::XDataSequence>
+ PivotTableDataProvider::assignFirstCategoriesToDataSequence()
+{
+ uno::Reference<chart2::data::XDataSequence> xDataSequence;
+
+ if (m_aCategoriesColumnOrientation.empty())
+ return xDataSequence;
+
+ std::vector<ValueAndFormat> const & rCategories = m_aCategoriesColumnOrientation[0];
+
+ std::unique_ptr<PivotTableDataSequence> pSequence;
+ pSequence.reset(new PivotTableDataSequence(m_pDocument, m_sPivotTableName,
+ lcl_identifierForCategories(), rCategories));
+ pSequence->setRole("categories");
+ xDataSequence.set(uno::Reference<chart2::data::XDataSequence>(pSequence.release()));
+
+ return xDataSequence;
+}
+
uno::Reference<chart2::data::XDataSource>
PivotTableDataProvider::createValuesDataSource()
{
@@ -636,27 +651,20 @@ uno::Reference<chart2::data::XDataSource>
uno::Reference<chart2::data::XDataSource> xDataSource;
std::vector<uno::Reference<chart2::data::XLabeledDataSequence>> aLabeledSequences;
+ // Fill first sequence of categories
{
- std::vector<ValueAndFormat> aFirstCategories;
- if (!m_aCategoriesColumnOrientation.empty())
- {
- std::copy(m_aCategoriesColumnOrientation[0].begin(),
- m_aCategoriesColumnOrientation[0].end(),
- std::back_inserter(aFirstCategories));
- }
uno::Reference<chart2::data::XLabeledDataSequence> xResult = newLabeledDataSequence();
- setLabeledDataSequenceValues(xResult, "categories", lcl_identifierForCategories(), aFirstCategories);
+ xResult->setValues(assignFirstCategoriesToDataSequence());
aLabeledSequences.push_back(xResult);
}
+ // Fill values and labels
{
for (size_t i = 0; i < m_aDataRowVector.size(); ++i)
{
uno::Reference<chart2::data::XLabeledDataSequence> xResult = newLabeledDataSequence();
-
xResult->setValues(assignValuesToDataSequence(i));
xResult->setLabel(assignLabelsToDataSequence(i));
-
aLabeledSequences.push_back(xResult);
}
}
@@ -802,19 +810,7 @@ uno::Reference<css::chart2::data::XDataSequence>
if (m_bNeedsUpdate)
collectPivotTableData();
- uno::Reference<chart2::data::XDataSequence> xDataSequence;
-
- if (m_aCategoriesColumnOrientation.empty())
- return xDataSequence;
-
- std::vector<ValueAndFormat> const & rCategories = m_aCategoriesColumnOrientation[0];
-
- std::unique_ptr<PivotTableDataSequence> pSequence;
- pSequence.reset(new PivotTableDataSequence(m_pDocument, m_sPivotTableName, lcl_identifierForCategories(), rCategories));
- pSequence->setRole("categories");
- xDataSequence.set(uno::Reference<chart2::data::XDataSequence>(pSequence.release()));
-
- return xDataSequence;
+ return assignFirstCategoriesToDataSequence();
}
OUString PivotTableDataProvider::getFieldOutputDescription(sal_Int32 nDimensionIndex)
More information about the Libreoffice-commits
mailing list