summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2019-12-18 09:49:26 +0100
committerLászló Németh <nemeth@numbertext.org>2020-01-10 14:21:35 +0100
commit6e847aa817999ab18acd534f9e6a86685bb268fc (patch)
tree640176e25db6e79ef4976b9fd6c527b684456c7d /oox
parent04b2310aaa094794ceedaa1bb6ff1823a2d29d3e (diff)
tdf#129859 XLSX import: don't show deleted legend entries
by adding a new feature to disable selected data points in pie charts. Fixing also tdf#129858 by deleting the correct legend entry in bar charts. Change-Id: Iaaf3a864e9404b8b6d3e2affbb366e18d0f4b43e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86160 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/chart/titleconverter.cxx61
-rw-r--r--oox/source/token/properties.txt1
2 files changed, 55 insertions, 7 deletions
diff --git a/oox/source/drawingml/chart/titleconverter.cxx b/oox/source/drawingml/chart/titleconverter.cxx
index c41a794763b1..e6591e1a5323 100644
--- a/oox/source/drawingml/chart/titleconverter.cxx
+++ b/oox/source/drawingml/chart/titleconverter.cxx
@@ -268,9 +268,13 @@ void LegendConverter::legendEntriesFormatting(const Reference<XDiagram>& rxDiagr
return;
sal_Int32 nIndex = 0;
- for (const auto& rCooSysSequence : xCooSysSequence)
+ for (const auto& rCooSys : xCooSysSequence)
{
- Reference<XChartTypeContainer> xChartTypeContainer(rCooSysSequence, UNO_QUERY_THROW);
+ PropertySet aCooSysProp(rCooSys);
+ bool bSwapXAndY = false;
+ aCooSysProp.getProperty(bSwapXAndY, PROP_SwapXAndYAxis);
+
+ Reference<XChartTypeContainer> xChartTypeContainer(rCooSys, UNO_QUERY_THROW);
const Sequence<Reference<XChartType>> xChartTypeSequence(xChartTypeContainer->getChartTypes());
if (!xChartTypeSequence.hasElements())
continue;
@@ -282,19 +286,62 @@ void LegendConverter::legendEntriesFormatting(const Reference<XDiagram>& rxDiagr
continue;
const Sequence<Reference<XDataSeries>> aDataSeriesSeq = xDSCont->getDataSeries();
+ if (bSwapXAndY)
+ nIndex += aDataSeriesSeq.getLength() - 1;
for (const auto& rDataSeries : aDataSeriesSeq)
{
PropertySet aSeriesProp(rDataSeries);
- for (const auto& rLegendEntry : mrModel.maLegendEntries)
+ bool bVaryColorsByPoint = false;
+ aSeriesProp.getProperty(bVaryColorsByPoint, PROP_VaryColorsByPoint);
+
+ if (bVaryColorsByPoint)
+ {
+ Reference<XDataSource> xDSrc(rDataSeries, UNO_QUERY);
+ if (!xDSrc.is())
+ continue;
+
+ const Sequence<Reference<XLabeledDataSequence> > aDataSeqs = xDSrc->getDataSequences();
+ std::vector<sal_Int32> deletedLegendEntries;
+ sal_Int32 j = 0;
+ for (const auto& rDataSeq : aDataSeqs)
+ {
+ Reference<XDataSequence> xValues = rDataSeq->getValues();
+ if (!xValues.is())
+ continue;
+
+ sal_Int32 nDataSeqSize = xValues->getData().getLength();
+ for (sal_Int32 i = 0; i < nDataSeqSize; ++i)
+ {
+ for (const auto& rLegendEntry : mrModel.maLegendEntries)
+ {
+ if (nIndex == rLegendEntry->mnLegendEntryIdx && rLegendEntry->mbLabelDeleted)
+ {
+ deletedLegendEntries.push_back(j + i);
+ break;
+ }
+ }
+ nIndex++;
+ }
+ j += nDataSeqSize;
+ }
+ if (deletedLegendEntries.size() > 0)
+ aSeriesProp.setProperty(PROP_DeletedLegendEntries, ContainerHelper::vectorToSequence(deletedLegendEntries));
+ }
+ else
{
- if (nIndex == rLegendEntry->mnLegendEntryIdx)
+ for (const auto& rLegendEntry : mrModel.maLegendEntries)
{
- aSeriesProp.setProperty(PROP_ShowLegendEntry, !rLegendEntry->mbLabelDeleted);
- break;
+ if (nIndex == rLegendEntry->mnLegendEntryIdx)
+ {
+ aSeriesProp.setProperty(PROP_ShowLegendEntry, !rLegendEntry->mbLabelDeleted);
+ break;
+ }
}
+ bSwapXAndY ? nIndex-- : nIndex++;
}
- nIndex++;
}
+ if (bSwapXAndY)
+ nIndex += aDataSeriesSeq.getLength() + 1;
}
}
}
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 2a9295367c11..b7a76058d688 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -132,6 +132,7 @@ DefaultSpinValue
DefaultState
DefaultText
DefaultValue
+DeletedLegendEntries
DiagonalBLTR
DiagonalTLBR
DialogLibraries