summaryrefslogtreecommitdiff
path: root/chart2/source/view
diff options
context:
space:
mode:
authorKurt Nordback <kurt.nordback@protonmail.com>2024-07-17 17:07:05 -0600
committerTomaž Vajngerl <quikee@gmail.com>2024-11-26 01:34:07 +0100
commitb10d331c1c9801adbf6d014d9348bb0a4dad3d2c (patch)
tree7fa23c258510338aedc321294e6962555f2f9265 /chart2/source/view
parent7c7e7da1538c1ed0c65821e18233ec9dcdc6cd2b (diff)
tdf#161800 - I/O of '# of values in second plot' parameter not supported
Add support for input and output of 'split position' parameter (number of entries in second plot) for of-pie charts. In OOXML this uses the supported split-pos tag. For ODF I added an extension in loext namespace for this parameter. This commit also includes simple tests for the I/O functionality in OOXML and ODF. Change-Id: I00ff59db721867fa836eb99b6677350040d005dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170666 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'chart2/source/view')
-rw-r--r--chart2/source/view/charttypes/PieChart.cxx21
-rw-r--r--chart2/source/view/charttypes/PieChart.hxx8
-rw-r--r--chart2/source/view/main/SeriesPlotterContainer.cxx6
3 files changed, 20 insertions, 15 deletions
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index 4bda2129817d..82ed7f32f6d4 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -195,7 +195,7 @@ PieChart::PieChart( const rtl::Reference<ChartType>& xChartTypeModel
, m_bUseRings(false)
, m_bSizeExcludesLabelsAndExplodedSegments(bExcludingPositioning)
, m_eSubType(PieChartSubType_NONE)
- , m_nCompositeSize(2)
+ , m_nSplitPos(2)
, m_fMaxOffset(std::numeric_limits<double>::quiet_NaN())
{
PlotterBase::m_pPosHelper = &m_aPosHelper;
@@ -230,7 +230,7 @@ PieChart::PieChart( const rtl::Reference<ChartType>& xChartTypeModel
}
try
{
- xChartTypeModel->getFastPropertyValue(PROP_PIECHARTTYPE_COMPOSITESIZE) >>= m_nCompositeSize; // "CompositeSize"
+ xChartTypeModel->getFastPropertyValue(PROP_PIECHARTTYPE_SPLIT_POS) >>= m_nSplitPos; // "CompositeSize"
}
catch( const uno::Exception& )
{
@@ -1050,7 +1050,7 @@ void PieChart::createShapes()
PieDataSrcBase *pDataSrc = nullptr;
PieDataSrc normalPieSrc;
- OfPieDataSrc ofPieSrc(m_nCompositeSize);
+ OfPieDataSrc ofPieSrc(m_nSplitPos);
// Default to regular pie if too few points for of-pie
::css::chart2::PieChartSubType eSubType =
@@ -2303,26 +2303,25 @@ uno::Reference< beans::XPropertySet > PieDataSrc::getProps(
// class OfPieDataSrc
//=======================
-// For now, just implement the default Excel behavior, which is that the
-// right pie consists of the last three entries in the series. Other
-// behaviors should be supported later.
+// Support data splits only of the type "last n entries go in right subchart",
+// for now.
// TODO
sal_Int32 OfPieDataSrc::getNPoints(const VDataSeries* pSeries,
enum SubPieType eType) const
{
if (eType == SubPieType::LEFT) {
- return pSeries->getTotalPointCount() - m_nCompositeSize + 1;
+ return pSeries->getTotalPointCount() - m_nSplitPos + 1;
} else {
assert(eType == SubPieType::RIGHT);
- return m_nCompositeSize;
+ return m_nSplitPos;
}
}
double OfPieDataSrc::getData(const VDataSeries* pSeries, sal_Int32 nPtIdx,
enum SubPieType eType) const
{
- const sal_Int32 n = pSeries->getTotalPointCount() - m_nCompositeSize;
+ const sal_Int32 n = pSeries->getTotalPointCount() - m_nSplitPos;
if (eType == SubPieType::LEFT) {
// nPtIdx should be in [0, n]
if (nPtIdx < n) {
@@ -2331,7 +2330,7 @@ double OfPieDataSrc::getData(const VDataSeries* pSeries, sal_Int32 nPtIdx,
// composite wedge
assert(nPtIdx == n);
double total = 0;
- for (sal_Int32 i = n; i < n + m_nCompositeSize; ++i) {
+ for (sal_Int32 i = n; i < n + m_nSplitPos; ++i) {
total += pSeries->getYValue(i);
}
return total;
@@ -2347,7 +2346,7 @@ uno::Reference< beans::XPropertySet > OfPieDataSrc::getProps(
enum SubPieType eType) const
{
const sal_Int32 nPts = pSeries->getTotalPointCount();
- const sal_Int32 n = nPts - m_nCompositeSize;
+ const sal_Int32 n = nPts - m_nSplitPos;
if (eType == SubPieType::LEFT) {
// nPtIdx should be in [0, n]
if (nPtIdx < n) {
diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx
index c5cb1e535cc8..b2fa3b8982ec 100644
--- a/chart2/source/view/charttypes/PieChart.hxx
+++ b/chart2/source/view/charttypes/PieChart.hxx
@@ -101,8 +101,8 @@ public:
class OfPieDataSrc : public PieDataSrcBase
{
public:
- OfPieDataSrc(sal_Int32 nCompositeSize):
- m_nCompositeSize(nCompositeSize)
+ OfPieDataSrc(sal_Int32 nSplitPos):
+ m_nSplitPos(nSplitPos)
{}
// Minimum sensible number of data points
@@ -118,7 +118,7 @@ public:
const VDataSeries* pSeries, sal_Int32 nPtIdx,
enum SubPieType eType) const;
private:
- sal_Int32 m_nCompositeSize;
+ double m_nSplitPos;
};
//=======================
@@ -276,7 +276,7 @@ private: //member
bool m_bSizeExcludesLabelsAndExplodedSegments;
::css::chart2::PieChartSubType m_eSubType;
// Number of entries in an of-pie composite wedge
- sal_Int32 m_nCompositeSize;
+ double m_nSplitPos;
struct PieLabelInfo
{
diff --git a/chart2/source/view/main/SeriesPlotterContainer.cxx b/chart2/source/view/main/SeriesPlotterContainer.cxx
index 43b62ae747ad..8ad97c3d1717 100644
--- a/chart2/source/view/main/SeriesPlotterContainer.cxx
+++ b/chart2/source/view/main/SeriesPlotterContainer.cxx
@@ -154,6 +154,7 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart
sal_Int32 nStartingAngle = 90;
sal_Int32 n3DRelativeHeight = 100;
PieChartSubType ePieChartSubType = PieChartSubType_NONE;
+ double nSplitPos = 2;
try
{
xDiagram->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= bSortByXValues;
@@ -167,6 +168,8 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart
xDiagram->getPropertyValue(u"3DRelativeHeight"_ustr) >>= n3DRelativeHeight;
}
xDiagram->getPropertyValue(u"SubPieType"_ustr) >>= ePieChartSubType;
+
+ xDiagram->getPropertyValue(u"SplitPos"_ustr) >>= nSplitPos;
}
catch (const uno::Exception&)
{
@@ -234,6 +237,9 @@ void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(ChartModel& rChart
uno::Any(ePieChartSubType));
// Reset the diagram-level property so it's not persistent.
xDiagram->setPropertyValue(u"SubPieType"_ustr, uno::Any(PieChartSubType_NONE));
+
+ xChartType->setFastPropertyValue(PROP_PIECHARTTYPE_SPLIT_POS, uno::Any(nSplitPos));
+ //xDiagram->setPropertyValue(u"SplitPos"_ustr, uno::Any(nSplitPos));
}
if (nT == 0)