summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-03-07 16:34:14 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-03-30 23:52:43 +0200
commit5be43b2a5dbf13075b0c1206451ec707d6130369 (patch)
treea8acbeda51a716d77d1330cccd721b4f1f93d93e
parenta8db9b42278fbbe573d24993b6575be627640fa0 (diff)
Pivot chart specific data provider to get pivot table output data
Change-Id: I6e1c4320316e7dcfad5b1de5d55403cfebd01a29
-rw-r--r--offapi/UnoApi_offapi.mk1
-rw-r--r--offapi/com/sun/star/chart2/data/XPivotChartDataProvider.idl54
-rw-r--r--sc/inc/PivotChartDataProvider.hxx13
-rw-r--r--sc/source/ui/unoobj/PivotChartDataProvider.cxx67
4 files changed, 128 insertions, 7 deletions
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 49602b9555e7..a7ae86dbb654 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2058,6 +2058,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/chart2/data,\
XLabeledDataSequence \
XLabeledDataSequence2 \
XNumericalDataSequence \
+ XPivotChartDataProvider \
XPopupRequest \
XRangeHighlighter \
XRangeXMLConversion \
diff --git a/offapi/com/sun/star/chart2/data/XPivotChartDataProvider.idl b/offapi/com/sun/star/chart2/data/XPivotChartDataProvider.idl
new file mode 100644
index 000000000000..95b58d4f1783
--- /dev/null
+++ b/offapi/com/sun/star/chart2/data/XPivotChartDataProvider.idl
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef com_sun_star_chart2_data_XPivotChartDataProvider_idl
+#define com_sun_star_chart2_data_XPivotChartDataProvider_idl
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/chart2/data/XDataSequence.idl>
+
+module com { module sun { module star { module chart2 { module data {
+
+/**
+ * Data provider specific for pivot chart data.
+ *
+ * @since LibreOffice 5.4
+ */
+interface XPivotChartDataProvider : com::sun::star::uno::XInterface
+{
+ /** names of column fields from the associated pivot table
+ *
+ * @since LibreOffice 5.4
+ */
+ sequence<string> getColumnFields();
+
+ /** names of row fields from the associated pivot table
+ *
+ * @since LibreOffice 5.4
+ */
+ sequence<string> getRowFields();
+
+ /** names of page fields from the associated pivot table
+ *
+ * @since LibreOffice 5.4
+ */
+ sequence<string> getPageFields();
+
+ /** names of data fields from the associated pivot table
+ *
+ * @since LibreOffice 5.4
+ */
+ sequence<string> getDataFields();
+};
+
+};};};};};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/PivotChartDataProvider.hxx b/sc/inc/PivotChartDataProvider.hxx
index 1c2df5af045a..097fb189a58c 100644
--- a/sc/inc/PivotChartDataProvider.hxx
+++ b/sc/inc/PivotChartDataProvider.hxx
@@ -16,6 +16,7 @@
#include "types.hxx"
#include <com/sun/star/chart2/data/XDataProvider.hpp>
+#include <com/sun/star/chart2/data/XPivotChartDataProvider.hpp>
#include <com/sun/star/chart2/data/XDataSource.hpp>
#include <com/sun/star/chart2/data/XDataSequence.hpp>
#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
@@ -40,6 +41,7 @@ namespace sc
class PivotChartItem;
typedef cppu::WeakImplHelper<css::chart2::data::XDataProvider,
+ css::chart2::data::XPivotChartDataProvider,
css::beans::XPropertySet,
css::lang::XServiceInfo,
css::util::XModifyBroadcaster>
@@ -76,6 +78,12 @@ public:
virtual css::uno::Reference< css::sheet::XRangeSelection > SAL_CALL getRangeSelection() override;
+ // XPivotChartDataProvider
+ virtual css::uno::Sequence<OUString> SAL_CALL getColumnFields() override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getRowFields() override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getPageFields() override;
+ virtual css::uno::Sequence<OUString> SAL_CALL getDataFields() override;
+
// XPropertySet
virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
@@ -152,6 +160,11 @@ private:
std::vector<std::vector<PivotChartItem>> m_aLabels;
std::vector<std::vector<PivotChartItem>> m_aDataRowVector;
+ std::vector<OUString> m_aColumnFields;
+ std::vector<OUString> m_aRowFields;
+ std::vector<OUString> m_aPageFields;
+ std::vector<OUString> m_aDataFields;
+
std::vector<css::uno::Reference<css::util::XModifyListener>> m_aValueListeners;
};
diff --git a/sc/source/ui/unoobj/PivotChartDataProvider.cxx b/sc/source/ui/unoobj/PivotChartDataProvider.cxx
index 37becafcb573..8b8e6ad166cc 100644
--- a/sc/source/ui/unoobj/PivotChartDataProvider.cxx
+++ b/sc/source/ui/unoobj/PivotChartDataProvider.cxx
@@ -249,6 +249,15 @@ void PivotChartDataProvider::collectPivotTableData(ScDPObject* pDPObject)
uno::Reference<sheet::XDataPilotResults> xDPResults(pDPObject->GetSource(), uno::UNO_QUERY);
uno::Sequence<uno::Sequence<sheet::DataResult>> xDataResultsSequence = xDPResults->getResults();
+ m_aCategoriesColumnOrientation.clear();
+ m_aCategoriesRowOrientation.clear();
+ m_aLabels.clear();
+ m_aDataRowVector.clear();
+ m_aColumnFields.clear();
+ m_aRowFields.clear();
+ m_aPageFields.clear();
+ m_aDataFields.clear();
+
double fNan;
rtl::math::setNan(&fNan);
@@ -273,6 +282,9 @@ void PivotChartDataProvider::collectPivotTableData(ScDPObject* pDPObject)
std::unordered_map<OUString, sal_Int32, OUStringHash> aDataFieldNumberFormatMap;
std::vector<OUString> aDataFieldNamesVectors;
+ std::unordered_map<OUString, OUString, OUStringHash> aDataFieldCaptionNames;
+ std::vector<OUString> aDataFieldNames;
+
sheet::DataPilotFieldOrientation eDataFieldOrientation = sheet::DataPilotFieldOrientation_HIDDEN;
for (long nDim = 0; nDim < xDims->getCount(); nDim++)
@@ -322,6 +334,8 @@ void PivotChartDataProvider::collectPivotTableData(ScDPObject* pDPObject)
{
case sheet::DataPilotFieldOrientation_COLUMN:
{
+ m_aColumnFields.push_back(xLevName->getName());
+
uno::Sequence<sheet::MemberResult> aSeq = xLevRes->getResults();
size_t i = 0;
OUString sCaption;
@@ -344,16 +358,22 @@ void PivotChartDataProvider::collectPivotTableData(ScDPObject* pDPObject)
if (bIsDataLayout)
{
+ // Remember data fields to determine the number format of data
aDataFieldNamesVectors.push_back(sName);
eDataFieldOrientation = sheet::DataPilotFieldOrientation_COLUMN;
+ // Remember the caption name
+ aDataFieldCaptionNames[rMember.Name] = rMember.Caption;
}
i++;
}
}
- break;
}
+ break;
+
case sheet::DataPilotFieldOrientation_ROW:
{
+ m_aRowFields.push_back(xLevName->getName());
+
uno::Sequence<sheet::MemberResult> aSeq = xLevRes->getResults();
m_aCategoriesRowOrientation.resize(aSeq.getLength());
size_t i = 0;
@@ -396,18 +416,31 @@ void PivotChartDataProvider::collectPivotTableData(ScDPObject* pDPObject)
if (bIsDataLayout)
{
+ // Remember data fields to determine the number format of data
aDataFieldNamesVectors.push_back(sName);
eDataFieldOrientation = sheet::DataPilotFieldOrientation_ROW;
+ // Remember the caption name
+ aDataFieldCaptionNames[rMember.Name] = rMember.Caption;
}
i++;
}
}
- break;
}
+ break;
+
+ case sheet::DataPilotFieldOrientation_PAGE:
+ {
+ m_aPageFields.push_back(xLevName->getName());
+ }
+ break;
+
case sheet::DataPilotFieldOrientation_DATA:
{
aDataFieldNumberFormatMap[xLevName->getName()] = nNumberFormat;
+ aDataFieldNames.push_back(xLevName->getName());
}
+ break;
+
default:
break;
}
@@ -415,6 +448,11 @@ void PivotChartDataProvider::collectPivotTableData(ScDPObject* pDPObject)
}
}
+ for (OUString const & rName : aDataFieldNames)
+ {
+ m_aDataFields.push_back(aDataFieldCaptionNames[rName]);
+ }
+
// Apply number format to the data
if (eDataFieldOrientation == sheet::DataPilotFieldOrientation_ROW)
{
@@ -448,11 +486,6 @@ void PivotChartDataProvider::collectPivotTableData(ScDPObject* pDPObject)
uno::Reference<chart2::data::XDataSource> PivotChartDataProvider::createPivotChartDataSource(OUString const & aRangeRepresentation)
{
- m_aCategoriesColumnOrientation.clear();
- m_aCategoriesRowOrientation.clear();
- m_aLabels.clear();
- m_aDataRowVector.clear();
-
uno::Reference<chart2::data::XDataSource> xDataSource;
std::vector<uno::Reference<chart2::data::XLabeledDataSequence>> aLabeledSequences;
@@ -570,6 +603,26 @@ uno::Reference<sheet::XRangeSelection> SAL_CALL PivotChartDataProvider::getRange
return xResult;
}
+uno::Sequence<OUString> PivotChartDataProvider::getColumnFields()
+{
+ return comphelper::containerToSequence(m_aColumnFields);
+}
+
+uno::Sequence<OUString> PivotChartDataProvider::getRowFields()
+{
+ return comphelper::containerToSequence(m_aRowFields);
+}
+
+uno::Sequence<OUString> PivotChartDataProvider::getPageFields()
+{
+ return comphelper::containerToSequence(m_aPageFields);
+}
+
+uno::Sequence<OUString> PivotChartDataProvider::getDataFields()
+{
+ return comphelper::containerToSequence(m_aDataFields);
+}
+
// XModifyBroadcaster ========================================================
void SAL_CALL PivotChartDataProvider::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )