Kaydet (Commit) d02d5288 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

tdf#107145 display applied filters for page field in pivot chart

Add field output description which shows the description of the
filtered output, which can be either "- all -" when nothing is
filtered, "- multiple -" when multiple values are outputted or
the specific value - the only value remaining.

Change-Id: I8fca6050dabba9878e9f3a31e4be7a03e3b87467
Reviewed-on: https://gerrit.libreoffice.org/37125Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst a3320166
...@@ -2498,7 +2498,8 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes, ...@@ -2498,7 +2498,8 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes,
return; return;
uno::Reference<beans::XPropertySet> xModelPage(rModel.getPageBackground()); uno::Reference<beans::XPropertySet> xModelPage(rModel.getPageBackground());
awt::Size aSize(3000, 700); // size of the button
awt::Size aSize(4000, 700); // size of the button
long x = 0; long x = 0;
...@@ -2511,8 +2512,10 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes, ...@@ -2511,8 +2512,10 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes,
std::unique_ptr<VButton> pButton(new VButton); std::unique_ptr<VButton> pButton(new VButton);
pButton->init(xPageShapes, xShapeFactory); pButton->init(xPageShapes, xShapeFactory);
awt::Point aNewPosition = awt::Point(rRemainingSpace.X + x + 100, rRemainingSpace.Y + 100); awt::Point aNewPosition = awt::Point(rRemainingSpace.X + x + 100, rRemainingSpace.Y + 100);
pButton->setLabel(rPageFieldEntry.Name); sal_Int32 nDimensionIndex = rPageFieldEntry.DimensionIndex;
pButton->setCID("FieldButton.Page." + OUString::number(rPageFieldEntry.DimensionIndex)); OUString aFieldOutputDescription = xPivotTableDataProvider->getFieldOutputDescription(nDimensionIndex);
pButton->setLabel(rPageFieldEntry.Name + " | " + aFieldOutputDescription);
pButton->setCID("FieldButton.Page." + OUString::number(nDimensionIndex));
pButton->setPosition(aNewPosition); pButton->setPosition(aNewPosition);
pButton->setSize(aSize); pButton->setSize(aSize);
if (rPageFieldEntry.HasHiddenMembers) if (rPageFieldEntry.HasHiddenMembers)
...@@ -2525,6 +2528,8 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes, ...@@ -2525,6 +2528,8 @@ void lcl_createButtons(const uno::Reference<drawing::XShapes>& xPageShapes,
rRemainingSpace.Height -= (aSize.Height + 100 + 100); rRemainingSpace.Height -= (aSize.Height + 100 + 100);
} }
aSize = awt::Size(3000, 700); // size of the button
if (xPivotTableDataProvider->getRowFields().hasElements()) if (xPivotTableDataProvider->getRowFields().hasElements())
{ {
x = 200; x = 200;
......
...@@ -85,6 +85,13 @@ interface XPivotTableDataProvider : com::sun::star::uno::XInterface ...@@ -85,6 +85,13 @@ interface XPivotTableDataProvider : com::sun::star::uno::XInterface
* @since LibreOffice 5.4 * @since LibreOffice 5.4
*/ */
XDataSequence createDataSequenceOfCategories(); XDataSequence createDataSequenceOfCategories();
/** field output description: either "- all -", "- multiple -", or specific value
*
* @param nDimensionIndex
* dimension index of the field
*/
string getFieldOutputDescription([in] long nDimensionIndex);
}; };
};};};};}; };};};};};
......
...@@ -97,6 +97,8 @@ public: ...@@ -97,6 +97,8 @@ public:
virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
createDataSequenceOfCategories() override; createDataSequenceOfCategories() override;
virtual OUString SAL_CALL getFieldOutputDescription(sal_Int32 nPageFieldIndex) override;
// XPropertySet // XPropertySet
virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
...@@ -170,6 +172,8 @@ private: ...@@ -170,6 +172,8 @@ private:
std::vector<css::chart2::data::PivotTableFieldEntry> m_aPageFields; std::vector<css::chart2::data::PivotTableFieldEntry> m_aPageFields;
std::vector<css::chart2::data::PivotTableFieldEntry> m_aDataFields; std::vector<css::chart2::data::PivotTableFieldEntry> m_aDataFields;
std::unordered_map<sal_Int32, OUString> m_aFieldOutputDescriptionMap;
bool m_bNeedsUpdate; bool m_bNeedsUpdate;
css::uno::Reference<css::uno::XComponentContext> m_xContext; css::uno::Reference<css::uno::XComponentContext> m_xContext;
......
...@@ -18,7 +18,9 @@ ...@@ -18,7 +18,9 @@
#include "document.hxx" #include "document.hxx"
#include "unonames.hxx" #include "unonames.hxx"
#include "docsh.hxx" #include "docsh.hxx"
#include "scresid.hxx"
#include "globstr.hrc" #include "globstr.hrc"
#include "scres.hrc"
#include "dpobject.hxx" #include "dpobject.hxx"
#include "hints.hxx" #include "hints.hxx"
...@@ -36,6 +38,7 @@ ...@@ -36,6 +38,7 @@
#include <com/sun/star/sheet/XLevelsSupplier.hpp> #include <com/sun/star/sheet/XLevelsSupplier.hpp>
#include <com/sun/star/sheet/XDataPilotMemberResults.hpp> #include <com/sun/star/sheet/XDataPilotMemberResults.hpp>
#include <com/sun/star/sheet/MemberResultFlags.hpp> #include <com/sun/star/sheet/MemberResultFlags.hpp>
#include <com/sun/star/sheet/XMembersSupplier.hpp>
#include <com/sun/star/chart/ChartDataChangeEvent.hpp> #include <com/sun/star/chart/ChartDataChangeEvent.hpp>
...@@ -86,6 +89,39 @@ OUString lcl_identifierForCategories() ...@@ -86,6 +89,39 @@ OUString lcl_identifierForCategories()
return "PT@" + constIdCategories; return "PT@" + constIdCategories;
} }
std::vector<OUString> lcl_getVisiblePageMembers(const uno::Reference<uno::XInterface> & xLevel)
{
std::vector<OUString> aResult;
if (!xLevel.is())
return aResult;
uno::Reference<sheet::XMembersSupplier> xMembersSupplier(xLevel, uno::UNO_QUERY);
if (!xMembersSupplier.is())
return aResult;
uno::Reference<sheet::XMembersAccess> xMembersAccess = xMembersSupplier->getMembers();
if (!xMembersAccess.is())
return aResult;
for (OUString const & rMemberNames : xMembersAccess->getElementNames())
{
uno::Reference<beans::XPropertySet> xProperties(xMembersAccess->getByName(rMemberNames), uno::UNO_QUERY);
if (!xProperties.is())
continue;
OUString aCaption = ScUnoHelpFunctions::GetStringProperty(xProperties, SC_UNO_DP_LAYOUTNAME, OUString());
if (aCaption.isEmpty())
aCaption = rMemberNames;
bool bVisible = ScUnoHelpFunctions::GetBoolProperty(xProperties, SC_UNO_DP_ISVISIBLE);
if (bVisible)
aResult.push_back(aCaption);
}
return aResult;
}
} // end anonymous namespace } // end anonymous namespace
SC_SIMPLE_SERVICE_INFO(PivotTableDataProvider, "PivotTableDataProvider", SC_SERVICENAME_CHART_PIVOTTABLE_DATAPROVIDER) SC_SIMPLE_SERVICE_INFO(PivotTableDataProvider, "PivotTableDataProvider", SC_SERVICENAME_CHART_PIVOTTABLE_DATAPROVIDER)
...@@ -261,6 +297,7 @@ void PivotTableDataProvider::collectPivotTableData() ...@@ -261,6 +297,7 @@ void PivotTableDataProvider::collectPivotTableData()
m_aRowFields.clear(); m_aRowFields.clear();
m_aPageFields.clear(); m_aPageFields.clear();
m_aDataFields.clear(); m_aDataFields.clear();
m_aFieldOutputDescriptionMap.clear();
uno::Reference<sheet::XDataPilotResults> xDPResults(pDPObject->GetSource(), uno::UNO_QUERY); uno::Reference<sheet::XDataPilotResults> xDPResults(pDPObject->GetSource(), uno::UNO_QUERY);
uno::Sequence<uno::Sequence<sheet::DataResult>> xDataResultsSequence = xDPResults->getResults(); uno::Sequence<uno::Sequence<sheet::DataResult>> xDataResultsSequence = xDPResults->getResults();
...@@ -447,6 +484,23 @@ void PivotTableDataProvider::collectPivotTableData() ...@@ -447,6 +484,23 @@ void PivotTableDataProvider::collectPivotTableData()
case sheet::DataPilotFieldOrientation_PAGE: case sheet::DataPilotFieldOrientation_PAGE:
{ {
m_aPageFields.push_back(chart2::data::PivotTableFieldEntry{xLevelName->getName(), nDim, nDimPos, bHasHiddenMember}); m_aPageFields.push_back(chart2::data::PivotTableFieldEntry{xLevelName->getName(), nDim, nDimPos, bHasHiddenMember});
// Resolve filtering
OUString aFieldOutputDescription;
if (bHasHiddenMember)
{
std::vector<OUString> aMembers = lcl_getVisiblePageMembers(xLevel);
if (aMembers.size() == 1)
aFieldOutputDescription = aMembers[0];
else
aFieldOutputDescription = ScResId(SCSTR_MULTIPLE).toString();
}
else
{
aFieldOutputDescription = ScResId(SCSTR_ALL).toString();
}
m_aFieldOutputDescriptionMap[nDim] = aFieldOutputDescription;
} }
break; break;
...@@ -763,6 +817,13 @@ uno::Reference<css::chart2::data::XDataSequence> ...@@ -763,6 +817,13 @@ uno::Reference<css::chart2::data::XDataSequence>
return xDataSequence; return xDataSequence;
} }
OUString PivotTableDataProvider::getFieldOutputDescription(sal_Int32 nDimensionIndex)
{
if (nDimensionIndex < 0)
return OUString();
return m_aFieldOutputDescriptionMap[size_t(nDimensionIndex)];
}
// XModifyBroadcaster ======================================================== // XModifyBroadcaster ========================================================
void SAL_CALL PivotTableDataProvider::addModifyListener(const uno::Reference< util::XModifyListener>& aListener) void SAL_CALL PivotTableDataProvider::addModifyListener(const uno::Reference< util::XModifyListener>& aListener)
......
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