summaryrefslogtreecommitdiff
path: root/xmloff/source/chart/SchXMLPlotAreaContext.cxx
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2020-02-05 13:37:00 +0100
committerLászló Németh <nemeth@numbertext.org>2020-02-13 11:15:56 +0100
commita96ec04a07c35338f5f9a0cb361b9322e5ca9cec (patch)
tree20b109bd965560010312b19d1dd3d8b01f05d76e /xmloff/source/chart/SchXMLPlotAreaContext.cxx
parent8daffb60dd2863878bb04317ca2849d76df01f4b (diff)
tdf#130225 implement ODF export of deleted legend entries of pie charts
Follow-up of the following commits related to the new UNO property DeletedLegendEntries for pie charts: commit 86be3422cd55fa9e44104f1628648061bb6a3495 (tdf#129857 Chart OOXML export: fix deleted legend entries) commit 6e847aa817999ab18acd534f9e6a86685bb268fc (tdf#129859 XLSX import: don't show deleted legend entries) Change-Id: Id24cddefa83e50dde1ec6555d02891753483dd5f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88018 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'xmloff/source/chart/SchXMLPlotAreaContext.cxx')
-rw-r--r--xmloff/source/chart/SchXMLPlotAreaContext.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/xmloff/source/chart/SchXMLPlotAreaContext.cxx b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
index 5ea889aa7621..dc32a9e900a0 100644
--- a/xmloff/source/chart/SchXMLPlotAreaContext.cxx
+++ b/xmloff/source/chart/SchXMLPlotAreaContext.cxx
@@ -31,6 +31,7 @@
#include <xmloff/xmluconv.hxx>
#include <xmloff/prstylei.hxx>
#include <xmloff/xmlstyle.hxx>
+#include <oox/helper/containerhelper.hxx>
#include <com/sun/star/awt/Point.hpp>
#include <com/sun/star/awt/Size.hpp>
@@ -679,6 +680,7 @@ void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttr
{
OUString sAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
+ bool bHideLegend = false;
sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
if( nPrefix == XML_NAMESPACE_CHART )
@@ -703,6 +705,23 @@ void SchXMLDataPointContext::StartElement( const uno::Reference< xml::sax::XAttr
sCustomLabelField = xAttrList->getValueByIndex( i );
mDataPoint.mCustomLabels.push_back(sCustomLabelField);
}
+ else if (IsXMLToken(aLocalName, XML_HIDE_LEGEND))
+ {
+ bHideLegend = xAttrList->getValueByIndex(i).toBoolean();
+ if (bHideLegend)
+ {
+ uno::Sequence<sal_Int32> deletedLegendEntriesSeq;
+ Reference<beans::XPropertySet> xSeriesProp(mDataPoint.m_xSeries, uno::UNO_QUERY);
+ xSeriesProp->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq;
+ std::vector<sal_Int32> deletedLegendEntries;
+ for (auto& deletedLegendEntry : deletedLegendEntriesSeq)
+ {
+ deletedLegendEntries.push_back(deletedLegendEntry);
+ }
+ deletedLegendEntries.push_back(mDataPoint.m_nPointIndex);
+ xSeriesProp->setPropertyValue("DeletedLegendEntries", uno::makeAny(::oox::ContainerHelper::vectorToSequence(deletedLegendEntries)));
+ }
+ }
}
}