tdf#50934: Fix compiler complaints and activate OOXML I/O tests

Add tests for input and output of very basic pie-of-pie and bar-of-pie
charts in OOXML.

Change-Id: I6441d99941ea2aca9bf58ede40dbe8f3d38a3291
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160742
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 81ed060..b46bc77 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -529,6 +529,28 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testDoughnutChart)
    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart"_ostr);
}

CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testPieOfPieChart)
{
    loadFromFile(u"xlsx/pieOfPieChart.xlsx");
    save("Calc Office Open XML");
    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
    CPPUNIT_ASSERT(pXmlDoc);

    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart"_ostr);
    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart/c:ofPieType[1]"_ostr, "val"_ostr, "pie");
}

CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testBarOfPieChart)
{
    loadFromFile(u"xlsx/barOfPieChart.xlsx");
    save("Calc Office Open XML");
    xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart1.xml");
    CPPUNIT_ASSERT(pXmlDoc);

    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart"_ostr);
    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:ofPieChart/c:ofPieType[1]"_ostr, "val"_ostr, "bar");
}

CPPUNIT_TEST_FIXTURE(Chart2ExportTest, testDisplayUnits)
{
    loadFromFile(u"docx/DisplayUnits.docx");
diff --git a/chart2/qa/extras/data/xlsx/barOfPieChart.xlsx b/chart2/qa/extras/data/xlsx/barOfPieChart.xlsx
new file mode 100644
index 0000000..227ab83
--- /dev/null
+++ b/chart2/qa/extras/data/xlsx/barOfPieChart.xlsx
Binary files differ
diff --git a/chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx b/chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx
index efb1c05..b3a1c35 100644
--- a/chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx
+++ b/chart2/qa/extras/data/xlsx/pieOfPieChart.xlsx
Binary files differ
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index b70fde7..ff8cf62 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -918,7 +918,7 @@ void PieChart::createShapes()

        // Default to regular pie if too few points for of-pie
        ::css::chart2::PieChartSubType eSubType =
            nPointCount >= OfPieDataSrc::minPoints() ?
            nPointCount >= OfPieDataSrc::minPoints ?
            m_eSubType :
            PieChartSubType_NONE;

@@ -1068,7 +1068,38 @@ void PieChart::createShapes()
    }//next x slot
}

void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType,
static sal_Int32 propIndex(
        sal_Int32 nPointIndex,
        enum SubPieType eType,
        const PieDataSrcBase *pDataSrc,
        VDataSeries* pSeries)
{

    switch (eType) {
    case SubPieType::LEFT:
        if (nPointIndex == pDataSrc->getNPoints(pSeries,
                    SubPieType::LEFT) - 1) {
            return pSeries->getTotalPointCount();
        } else {
            return nPointIndex;
        }
        break;
    case SubPieType::RIGHT:
        return pDataSrc->getNPoints(pSeries, SubPieType::LEFT) +
            nPointIndex - 1;
        break;
    case SubPieType::NONE:
        return nPointIndex;
        break;
    default: // shouldn't happen
        assert(false);
        return 0; // suppress compile warning
    }
}


void PieChart::createOneRing(
        enum SubPieType eType,
        double fSlotX,
        ShapeParam& aParam,
        const rtl::Reference<SvxShapeGroupAnyD>& xSeriesTarget,
@@ -1187,11 +1218,9 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType,
                        bConcentricExplosion);

            // Handle coloring of the composite wedge
            const sal_Int32 nPropIdx = (
                    eType == SubPieType::LEFT &&
                    nPointIndex == pDataSrc->getNPoints(pSeries, SubPieType::LEFT) - 1 ?
                    pSeries->getTotalPointCount() :
                    nPointIndex);
            sal_Int32 nPropIdx = propIndex(nPointIndex, eType, pDataSrc,
                    pSeries);

            ///point color:
            if (!pSeries->hasPointOwnColor(nPropIdx) && m_xColorScheme.is())
            {
@@ -1210,12 +1239,13 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType,
            }

            ///create label
            createTextLabelShape(xTextTarget, *pSeries, nPointIndex, aParam);
            createTextLabelShape(xTextTarget, *pSeries, nPropIdx, aParam);

            if(!bDoExplode)
            {
                ShapeFactory::setShapeName( xPointShape
                            , ObjectIdentifier::createPointCID( pSeries->getPointCID_Stub(), nPointIndex ) );
                            , ObjectIdentifier::createPointCID(
                                pSeries->getPointCID_Stub(), nPropIdx ) );
            }
            else try
            {
@@ -1242,7 +1272,8 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType,
                    ) );

                ShapeFactory::setShapeName( xPointShape
                            , ObjectIdentifier::createPointCID( aPointCIDStub, nPointIndex ) );
                            , ObjectIdentifier::createPointCID( aPointCIDStub,
                                nPropIdx ) );
            }
            catch( const uno::Exception& )
            {
@@ -1301,17 +1332,19 @@ void PieChart::createOneBar(
                    xPointProperties, aParam,
                    fBarBottom, fBarTop);

        sal_Int32 nPropIdx = propIndex(nPointIndex, eType, pDataSrc, pSeries);

        ///point color:
        if (!pSeries->hasPointOwnColor(nPointIndex) && m_xColorScheme.is())
        if (!pSeries->hasPointOwnColor(nPropIdx) && m_xColorScheme.is())
        {
            xPointShape->setPropertyValue("FillColor",
                uno::Any(m_xColorScheme->getColorByIndex( nPointIndex )));
                uno::Any(m_xColorScheme->getColorByIndex( nPropIdx )));
        }


        if(bHasFillColorMapping)
        {
            double nPropVal = pSeries->getValueByProperty(nPointIndex, "FillColor");
            double nPropVal = pSeries->getValueByProperty(nPropIdx, "FillColor");
            if(!std::isnan(nPropVal))
            {
                xPointShape->setPropertyValue("FillColor", uno::Any(static_cast<sal_Int32>( nPropVal)));
@@ -1319,11 +1352,11 @@ void PieChart::createOneBar(
        }

        ///create label
        createTextLabelShape(xTextTarget, *pSeries, nPointIndex, aParam);
        createTextLabelShape(xTextTarget, *pSeries, nPropIdx, aParam);

        ShapeFactory::setShapeName( xPointShape,
                ObjectIdentifier::createPointCID( pSeries->getPointCID_Stub(),
                    nPointIndex ) );
                    nPropIdx ) );
    }//next category
}

diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx
index abcf1cc..bf11f6c 100644
--- a/chart2/source/view/charttypes/PieChart.hxx
+++ b/chart2/source/view/charttypes/PieChart.hxx
@@ -102,7 +102,7 @@ class OfPieDataSrc : public PieDataSrcBase
{
public:
    // Minimum sensible number of data points
    static sal_Int32 minPoints() { return 4; }
    static constexpr sal_Int32 minPoints = 4;

    sal_Int32 getNPoints(const VDataSeries* pSeries,
                enum SubPieType eType) const;