chart2/qa/extras/chart2dump/chart2dump.cxx | 1555 +++++++++++++++-------------- 1 file changed, 856 insertions(+), 699 deletions(-)
New commits: commit 73a558942d519bd72ef8fb8891ceae559654cd6a Author: Xisco Fauli <[email protected]> AuthorDate: Thu Feb 5 17:20:05 2026 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Feb 6 00:30:08 2026 +0100 CppunitTest_chart2_dump: split single test into different ones so every document is loaded in different tests Change-Id: I7a34cb2cb11fc1b073f983afc222354f02034763 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198769 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/chart2/qa/extras/chart2dump/chart2dump.cxx b/chart2/qa/extras/chart2dump/chart2dump.cxx index aa9f82962b3e..26a4207b79f2 100644 --- a/chart2/qa/extras/chart2dump/chart2dump.cxx +++ b/chart2/qa/extras/chart2dump/chart2dump.cxx @@ -88,7 +88,7 @@ protected: OUString const & getTestFileName() const { return m_sTestFileName; } - void setTestFileName(const OUString& sName, std::u16string_view aTestName, bool bDumpMode=false) + void setTestFileName (const OUString& sName, std::u16string_view aTestName, bool bDumpMode=false) { m_bDumpMode = bDumpMode; m_sTestFileName = sName; @@ -223,6 +223,17 @@ protected: OUString::number(rTransform.Line3.Column1) + ";" + OUString::number(rTransform.Line3.Column2) + ";" + OUString::number(rTransform.Line3.Column3); } + void testChartData(const OUString& rTestFile); + void testLegend(const OUString& rTestFile); + void testGrid(const OUString& rTestFile); + void testAxisGeometry(const OUString& rTestFile); + void testAxisLabel(const OUString& rTestFile); + void testColumnBar(const OUString& rTestFile); + void testChartWall(const OUString& rTestFile); + void testPieChart(const OUString& rTestFile); + void testAreaChart(const OUString& rTestFile); + void testPointLineChart(const OUString& rTestFile); + private: OUString m_sTestFileName; bool m_bDumpMode; @@ -230,817 +241,963 @@ private: std::ofstream m_aDumpFile; }; -CPPUNIT_TEST_FIXTURE(Chart2DumpTest, ChartDataTest) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testSimpleChart) +{ + testChartData(u"simple_chart.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testMultipleCategories) +{ + testChartData(u"multiple_categories.ods"_ustr); +} + +void Chart2DumpTest::testChartData(const OUString& rTestFile) { - const std::vector<OUString> aTestFiles = + setTestFileName(rTestFile, u"chartdatatest"); + loadFromFile(getTestFileName()); + uno::Reference< chart::XChartDocument > xChartDoc (getChartDocFromSheet(0), UNO_QUERY_THROW); + + // Check title + uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); + Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW); + uno::Reference<chart2::XTitle> xTitle = xTitled->getTitleObject(); + if(xTitle.is()) { - u"simple_chart.ods"_ustr, - u"multiple_categories.ods"_ustr - }; + OUString sChartTitle = getTitleString(xTitled); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sChartTitle); + } - for (const OUString& aTestFile : aTestFiles) + // Check chart type + Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); + CPPUNIT_ASSERT(xChartType.is()); + OUString sChartType = xChartType->getChartType(); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sChartType); + + // Check axis titles and number format + // x Axis + Reference<chart2::XAxis> xAxis = getAxisFromDoc(xChartDoc2, 0, 0, 0); + Reference<chart2::XTitled> xAxisTitled(xAxis, UNO_QUERY_THROW); + uno::Reference<chart2::XTitle> xAxisTitle = xAxisTitled->getTitleObject(); + if (xAxisTitle.is()) { - setTestFileName(aTestFile, u"chartdatatest"); - loadFromFile(getTestFileName()); - uno::Reference< chart::XChartDocument > xChartDoc (getChartDocFromSheet(0), UNO_QUERY_THROW); - - // Check title - uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); - Reference<chart2::XTitled> xTitled(xChartDoc, uno::UNO_QUERY_THROW); - uno::Reference<chart2::XTitle> xTitle = xTitled->getTitleObject(); - if(xTitle.is()) - { - OUString sChartTitle = getTitleString(xTitled); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sChartTitle); - } + OUString sXAxisTitle = getTitleString(xAxisTitled); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sXAxisTitle); + } + sal_Int32 nXAxisNumberFormat = getNumberFormatFromAxis(xAxis); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nXAxisNumberFormat); + sal_Int16 nXAxisNumberType = getNumberFormatType(xChartDoc2, nXAxisNumberFormat); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nXAxisNumberType); + + // y Axis + xAxis.set(getAxisFromDoc(xChartDoc2, 0, 1, 0)); + xAxisTitled.set(xAxis, UNO_QUERY_THROW); + xAxisTitle.set(xAxisTitled->getTitleObject()); + if (xAxisTitle.is()) + { + OUString sYAxisTitle = getTitleString(xAxisTitled); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sYAxisTitle); + } + sal_Int32 nYAxisNumberFormat = getNumberFormatFromAxis(xAxis); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nYAxisNumberFormat); + sal_Int16 nYAxisNumberType = getNumberFormatType(xChartDoc2, nYAxisNumberFormat); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nYAxisNumberType); + + // Check column labels + uno::Reference< chart::XChartDataArray > xChartData(xChartDoc->getData(), UNO_QUERY_THROW); + uno::Sequence < OUString > aColumnLabels = xChartData->getColumnDescriptions(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(aColumnLabels.getLength()); + OUString sColumnLabels = sequenceToOneLineString(aColumnLabels); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sColumnLabels); + + // Check row labels + uno::Sequence< OUString > aRowLabels = xChartData->getRowDescriptions(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(aRowLabels.getLength()); + OUString sRowLabels = sequenceToOneLineString(aRowLabels); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sRowLabels); + + // Check Y values + std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(aDataSeriesYValues.size()); + for (const std::vector<double>& aYValuesOfSeries : aDataSeriesYValues) + { + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(aYValuesOfSeries.size()); + OUString sYValuesOfSeries = doubleVectorToOneLineString(aYValuesOfSeries); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sYValuesOfSeries); + } - // Check chart type - Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); - CPPUNIT_ASSERT(xChartType.is()); - OUString sChartType = xChartType->getChartType(); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sChartType); - - // Check axis titles and number format - // x Axis - Reference<chart2::XAxis> xAxis = getAxisFromDoc(xChartDoc2, 0, 0, 0); - Reference<chart2::XTitled> xAxisTitled(xAxis, UNO_QUERY_THROW); - uno::Reference<chart2::XTitle> xAxisTitle = xAxisTitled->getTitleObject(); - if (xAxisTitle.is()) - { - OUString sXAxisTitle = getTitleString(xAxisTitled); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sXAxisTitle); - } - sal_Int32 nXAxisNumberFormat = getNumberFormatFromAxis(xAxis); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nXAxisNumberFormat); - sal_Int16 nXAxisNumberType = getNumberFormatType(xChartDoc2, nXAxisNumberFormat); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nXAxisNumberType); - - // y Axis - xAxis.set(getAxisFromDoc(xChartDoc2, 0, 1, 0)); - xAxisTitled.set(xAxis, UNO_QUERY_THROW); - xAxisTitle.set(xAxisTitled->getTitleObject()); - if (xAxisTitle.is()) + // Check source ranges + for (size_t nIndex = 0; nIndex < aDataSeriesYValues.size(); ++nIndex) + { + Reference< chart2::data::XDataSequence > xDataSeq = getDataSequenceFromDocByRole(xChartDoc2, u"values-x", nIndex); + if (xDataSeq.is()) { - OUString sYAxisTitle = getTitleString(xAxisTitled); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sYAxisTitle); + OUString aXValuesSourceRange = xDataSeq->getSourceRangeRepresentation(); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(aXValuesSourceRange); } - sal_Int32 nYAxisNumberFormat = getNumberFormatFromAxis(xAxis); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nYAxisNumberFormat); - sal_Int16 nYAxisNumberType = getNumberFormatType(xChartDoc2, nYAxisNumberFormat); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nYAxisNumberType); - - // Check column labels - uno::Reference< chart::XChartDataArray > xChartData(xChartDoc->getData(), UNO_QUERY_THROW); - uno::Sequence < OUString > aColumnLabels = xChartData->getColumnDescriptions(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(aColumnLabels.getLength()); - OUString sColumnLabels = sequenceToOneLineString(aColumnLabels); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sColumnLabels); - - // Check row labels - uno::Sequence< OUString > aRowLabels = xChartData->getRowDescriptions(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(aRowLabels.getLength()); - OUString sRowLabels = sequenceToOneLineString(aRowLabels); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sRowLabels); - - // Check Y values - std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(aDataSeriesYValues.size()); - for (const std::vector<double>& aYValuesOfSeries : aDataSeriesYValues) + xDataSeq.set(getDataSequenceFromDocByRole(xChartDoc2, u"values-y", nIndex)); + if (xDataSeq.is()) { - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(aYValuesOfSeries.size()); - OUString sYValuesOfSeries = doubleVectorToOneLineString(aYValuesOfSeries); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sYValuesOfSeries); + OUString aYValuesSourceRange = xDataSeq->getSourceRangeRepresentation(); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(aYValuesSourceRange); } - - // Check source ranges - for (size_t nIndex = 0; nIndex < aDataSeriesYValues.size(); ++nIndex) + xDataSeq.set(getDataSequenceFromDocByRole(xChartDoc2, u"categories", nIndex)); + if (xDataSeq.is()) { - Reference< chart2::data::XDataSequence > xDataSeq = getDataSequenceFromDocByRole(xChartDoc2, u"values-x", nIndex); - if (xDataSeq.is()) - { - OUString aXValuesSourceRange = xDataSeq->getSourceRangeRepresentation(); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(aXValuesSourceRange); - } - xDataSeq.set(getDataSequenceFromDocByRole(xChartDoc2, u"values-y", nIndex)); - if (xDataSeq.is()) - { - OUString aYValuesSourceRange = xDataSeq->getSourceRangeRepresentation(); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(aYValuesSourceRange); - } - xDataSeq.set(getDataSequenceFromDocByRole(xChartDoc2, u"categories", nIndex)); - if (xDataSeq.is()) - { - OUString aCategoriesSourceRange = xDataSeq->getSourceRangeRepresentation(); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(aCategoriesSourceRange); - } + OUString aCategoriesSourceRange = xDataSeq->getSourceRangeRepresentation(); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(aCategoriesSourceRange); } } } -CPPUNIT_TEST_FIXTURE(Chart2DumpTest, LegendTest) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testLegendOnRightSide) { - const std::vector<OUString> aTestFiles = - { - u"legend_on_right_side.odp"_ustr, - u"legend_on_bottom.odp"_ustr, - u"legend_on_left_side.odp"_ustr, - u"legend_on_top.odp"_ustr, - u"many_legend_entries.odp"_ustr, - u"custom_legend_position.odp"_ustr, - u"multiple_categories.odp"_ustr, - u"minimal_legend_test.odp"_ustr - }; + testLegend(u"legend_on_right_side.odp"_ustr); +} - for (const OUString& aTestFile : aTestFiles) - { - setTestFileName(aTestFile, u"legendtest"); - loadFromFile(getTestFileName()); - uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0, 0), UNO_SET_THROW); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xShapes.is()); - - // Get legend shape - uno::Reference<drawing::XShape> xLegend = getShapeByName(xShapes, u"CID/D=0:Legend="_ustr); - CPPUNIT_ASSERT(xLegend.is()); - - /* Check legend position and size - awt::Point aLegendPosition = xLegend->getPosition(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendPosition.X, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendPosition.Y, INT_EPS); - awt::Size aLegendSize = xLegend->getSize(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendSize.Width, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendSize.Height, INT_EPS);*/ - - // Check legend entries - uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); - Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); - CPPUNIT_ASSERT(xChartType.is()); - std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); - size_t nLegendEntryCount = aDataSeriesYValues.size(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nLegendEntryCount); - // Check legend entries geometry - for (size_t nSeriesIndex = 0; nSeriesIndex < nLegendEntryCount; ++nSeriesIndex) - { - uno::Reference<drawing::XShape> xLegendEntry = getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=" + OUString::number(nSeriesIndex) + ":LegendEntry=0"); - CPPUNIT_ASSERT(xLegendEntry.is()); +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testLegendOnBottom) +{ + testLegend(u"legend_on_bottom.odp"_ustr); +} - /* Check position and size - awt::Point aLegendEntryPosition = xLegendEntry->getPosition(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendEntryPosition.X, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendEntryPosition.Y, INT_EPS); - awt::Size aLegendEntrySize = xLegendEntry->getSize(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendEntrySize.Height, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendEntrySize.Width, INT_EPS); +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testLegendOnLeftSide) +{ + testLegend(u"legend_on_left_side.odp"_ustr); +} - // Check transformation - Reference< beans::XPropertySet > xLegendEntryPropSet(xLegendEntry, UNO_QUERY_THROW); - drawing::HomogenMatrix3 aLegendEntryTransformation; - xLegendEntryPropSet->getPropertyValue("Transformation") >>= aLegendEntryTransformation; - CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aLegendEntryTransformation, INT_EPS);*/ - - uno::Reference<container::XIndexAccess> xLegendEntryContainer(xLegendEntry, UNO_QUERY_THROW); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(xLegendEntryContainer->getCount()); - for (sal_Int32 nEntryGeometryElement = 1; nEntryGeometryElement < xLegendEntryContainer->getCount(); ++nEntryGeometryElement) - { - uno::Reference<drawing::XShape> xLegendEntryGeom(xLegendEntryContainer->getByIndex(nEntryGeometryElement), UNO_QUERY_THROW); - - // Check geometry - uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xLegendEntryGeom, uno::UNO_QUERY_THROW); - OUString sEntryGeomShapeType = xShapeDescriptor->getShapeType(); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sEntryGeomShapeType); - - // Check display color - Reference< beans::XPropertySet > xPropSet(xLegendEntryGeom, UNO_QUERY_THROW); - util::Color aEntryGeomColor = 0; - xPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aEntryGeomColor; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aEntryGeomColor)); - } - } - // Check legend entries' text - uno::Reference<container::XIndexAccess> xLegendContainer(xLegend, UNO_QUERY_THROW); - for (sal_Int32 i = 0; i < xLegendContainer->getCount(); ++i) - { - uno::Reference<drawing::XShape> xShape(xLegendContainer->getByIndex(i), uno::UNO_QUERY); - uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY_THROW); - OUString sShapeType = xShapeDescriptor->getShapeType(); +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testLegendOnTop) +{ + testLegend(u"legend_on_top.odp"_ustr); +} - if (sShapeType == "com.sun.star.drawing.TextShape") - { - uno::Reference<text::XText> xLegendEntryText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText(); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(xLegendEntryText->getString()); - } - } - } +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testManyLegendEntries) +{ + testLegend(u"many_legend_entries.odp"_ustr); } -CPPUNIT_TEST_FIXTURE(Chart2DumpTest, GridTest) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testCustomLegendPosition) { - const std::vector<OUString> aTestFiles = - { - u"vertical_grid.ods"_ustr, - u"horizontal_grid.ods"_ustr, - u"minor_grid.ods"_ustr, - u"formated_grid_line.ods"_ustr - }; + testLegend(u"custom_legend_position.odp"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testLegendMultipleCategories) +{ + testLegend(u"multiple_categories.odp"_ustr); +} - for (const OUString& sTestFile : aTestFiles) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testMinimalLegend) +{ + testLegend(u"minimal_legend_test.odp"_ustr); +} + +void Chart2DumpTest::testLegend(const OUString& rTestFile) +{ + setTestFileName(rTestFile, u"legendtest"); + loadFromFile(getTestFileName()); + uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0, 0), UNO_SET_THROW); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapes.is()); + + // Get legend shape + uno::Reference<drawing::XShape> xLegend = getShapeByName(xShapes, u"CID/D=0:Legend="_ustr); + CPPUNIT_ASSERT(xLegend.is()); + + /* Check legend position and size + awt::Point aLegendPosition = xLegend->getPosition(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendPosition.X, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendPosition.Y, INT_EPS); + awt::Size aLegendSize = xLegend->getSize(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendSize.Width, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendSize.Height, INT_EPS);*/ + + // Check legend entries + uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); + Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); + CPPUNIT_ASSERT(xChartType.is()); + std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); + size_t nLegendEntryCount = aDataSeriesYValues.size(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nLegendEntryCount); + // Check legend entries geometry + for (size_t nSeriesIndex = 0; nSeriesIndex < nLegendEntryCount; ++nSeriesIndex) { - setTestFileName(sTestFile, u"gridtest"); - loadFromFile(getTestFileName()); - uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromSheet(0), UNO_QUERY_THROW); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xShapes.is()); - - const std::vector<OUString> aGridShapeNames = - { - u"CID/D=0:CS=0:Axis=1,0:Grid=0"_ustr, // Major vertical grid - u"CID/D=0:CS=0:Axis=0,0:Grid=0"_ustr, // Major horizontal grid - u"CID/D=0:CS=0:Axis=1,0:Grid=0:SubGrid=0"_ustr, // Minor vertical grid - u"CID/D=0:CS=0:Axis=0,0:Grid=0:SubGrid=0"_ustr // Minor horizontal grid - }; + uno::Reference<drawing::XShape> xLegendEntry = getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=" + OUString::number(nSeriesIndex) + ":LegendEntry=0"); + CPPUNIT_ASSERT(xLegendEntry.is()); - for (const OUString& sGridShapeName : aGridShapeNames) + /* Check position and size + awt::Point aLegendEntryPosition = xLegendEntry->getPosition(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendEntryPosition.X, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendEntryPosition.Y, INT_EPS); + awt::Size aLegendEntrySize = xLegendEntry->getSize(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendEntrySize.Height, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLegendEntrySize.Width, INT_EPS); + + // Check transformation + Reference< beans::XPropertySet > xLegendEntryPropSet(xLegendEntry, UNO_QUERY_THROW); + drawing::HomogenMatrix3 aLegendEntryTransformation; + xLegendEntryPropSet->getPropertyValue("Transformation") >>= aLegendEntryTransformation; + CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aLegendEntryTransformation, INT_EPS);*/ + + uno::Reference<container::XIndexAccess> xLegendEntryContainer(xLegendEntry, UNO_QUERY_THROW); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(xLegendEntryContainer->getCount()); + for (sal_Int32 nEntryGeometryElement = 1; nEntryGeometryElement < xLegendEntryContainer->getCount(); ++nEntryGeometryElement) { - uno::Reference<drawing::XShape> xGrid = getShapeByName(xShapes, sGridShapeName); - if (xGrid.is()) - { - CPPUNIT_DUMP_ASSERT_NOTE(sGridShapeName); - // Check position and size - awt::Point aGridPosition = xGrid->getPosition(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aGridPosition.X, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aGridPosition.Y, INT_EPS); - awt::Size aGridSize = xGrid->getSize(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aGridSize.Height, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aGridSize.Width, INT_EPS); + uno::Reference<drawing::XShape> xLegendEntryGeom(xLegendEntryContainer->getByIndex(nEntryGeometryElement), UNO_QUERY_THROW); + + // Check geometry + uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xLegendEntryGeom, uno::UNO_QUERY_THROW); + OUString sEntryGeomShapeType = xShapeDescriptor->getShapeType(); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sEntryGeomShapeType); + + // Check display color + Reference< beans::XPropertySet > xPropSet(xLegendEntryGeom, UNO_QUERY_THROW); + util::Color aEntryGeomColor = 0; + xPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aEntryGeomColor; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aEntryGeomColor)); + } + } + // Check legend entries' text + uno::Reference<container::XIndexAccess> xLegendContainer(xLegend, UNO_QUERY_THROW); + for (sal_Int32 i = 0; i < xLegendContainer->getCount(); ++i) + { + uno::Reference<drawing::XShape> xShape(xLegendContainer->getByIndex(i), uno::UNO_QUERY); + uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xShape, uno::UNO_QUERY_THROW); + OUString sShapeType = xShapeDescriptor->getShapeType(); - // Check transformation - Reference< beans::XPropertySet > xPropSet(xGrid, UNO_QUERY_THROW); - drawing::HomogenMatrix3 aGridTransformation; - xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aGridTransformation; - CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aGridTransformation, INT_EPS); - - // Check line properties - uno::Reference<container::XIndexAccess> xIndexAccess(xGrid, UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xGridLine(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); - Reference< beans::XPropertySet > xGridLinePropSet(xGridLine, UNO_QUERY_THROW); - // Line type - drawing::LineDash aLineDash; - xGridLinePropSet->getPropertyValue(u"LineDash"_ustr) >>= aLineDash; - OUString sGridLineDash = - OUString::number(static_cast<sal_Int32>(aLineDash.Style)) + ";" + OUString::number(aLineDash.Dots) + ";" + OUString::number(aLineDash.DotLen) + - OUString::number(aLineDash.Dashes) + ";" + OUString::number(aLineDash.DashLen) + ";" + OUString::number(aLineDash.Distance); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sGridLineDash); - // Line color - util::Color aLineColor = 0; - xGridLinePropSet->getPropertyValue(u"LineColor"_ustr) >>= aLineColor; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aLineColor)); - // Line width - sal_Int32 nLineWidth = 0; - xGridLinePropSet->getPropertyValue(u"LineWidth"_ustr) >>= nLineWidth; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nLineWidth); - } + if (sShapeType == "com.sun.star.drawing.TextShape") + { + uno::Reference<text::XText> xLegendEntryText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText(); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(xLegendEntryText->getString()); } } } -CPPUNIT_TEST_FIXTURE(Chart2DumpTest, AxisGeometryTest) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testVerticalGrid) +{ + testGrid(u"vertical_grid.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testHorizontalGrid) +{ + testGrid(u"horizontal_grid.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testMinorGrid) +{ + testGrid(u"minor_grid.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testFormattedGridLine) +{ + testGrid(u"formated_grid_line.ods"_ustr); +} + +void Chart2DumpTest::testGrid(const OUString& rTestFile) { - const std::vector<OUString> aTestFiles = + setTestFileName(rTestFile, u"gridtest"); + loadFromFile(getTestFileName()); + uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromSheet(0), UNO_QUERY_THROW); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapes.is()); + + const std::vector<OUString> aGridShapeNames = { - u"default_formated_axis.odp"_ustr, - u"axis_special_positioning.odp"_ustr, - u"formated_axis_lines.odp"_ustr, - u"rotated_axis_labels.odp"_ustr + u"CID/D=0:CS=0:Axis=1,0:Grid=0"_ustr, // Major vertical grid + u"CID/D=0:CS=0:Axis=0,0:Grid=0"_ustr, // Major horizontal grid + u"CID/D=0:CS=0:Axis=1,0:Grid=0:SubGrid=0"_ustr, // Minor vertical grid + u"CID/D=0:CS=0:Axis=0,0:Grid=0:SubGrid=0"_ustr // Minor horizontal grid }; - for (const OUString& sTestFile : aTestFiles) + for (const OUString& sGridShapeName : aGridShapeNames) { - setTestFileName(sTestFile, u"axisgeometrytest"); - loadFromFile(getTestFileName()); - uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0, 0), UNO_SET_THROW); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xShapes.is()); - - const std::vector<OUString> aAxisShapeNames = - { - u"CID/D=0:CS=0:Axis=0,0"_ustr, // X Axis - u"CID/D=0:CS=0:Axis=1,0"_ustr, // Y Axis - }; - - for (const OUString& sAxisShapeName : aAxisShapeNames) + uno::Reference<drawing::XShape> xGrid = getShapeByName(xShapes, sGridShapeName); + if (xGrid.is()) { - uno::Reference<drawing::XShape> xXAxis = getShapeByName(xShapes, sAxisShapeName); - CPPUNIT_ASSERT(xXAxis.is()); - - CPPUNIT_DUMP_ASSERT_NOTE(sAxisShapeName); + CPPUNIT_DUMP_ASSERT_NOTE(sGridShapeName); // Check position and size - awt::Point aAxisPosition = xXAxis->getPosition(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAxisPosition.X, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAxisPosition.Y, INT_EPS); - awt::Size aAxisSize = xXAxis->getSize(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAxisSize.Height, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAxisSize.Width, INT_EPS); + awt::Point aGridPosition = xGrid->getPosition(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aGridPosition.X, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aGridPosition.Y, INT_EPS); + awt::Size aGridSize = xGrid->getSize(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aGridSize.Height, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aGridSize.Width, INT_EPS); // Check transformation - Reference< beans::XPropertySet > xPropSet(xXAxis, UNO_QUERY_THROW); - drawing::HomogenMatrix3 aAxisTransformation; - xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aAxisTransformation; - CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aAxisTransformation, INT_EPS); + Reference< beans::XPropertySet > xPropSet(xGrid, UNO_QUERY_THROW); + drawing::HomogenMatrix3 aGridTransformation; + xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aGridTransformation; + CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aGridTransformation, INT_EPS); // Check line properties - uno::Reference<container::XIndexAccess> xIndexAccess(xXAxis, UNO_QUERY_THROW); - sal_Int32 nAxisGeometriesCount = xIndexAccess->getCount(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nAxisGeometriesCount); - uno::Reference<drawing::XShape> xAxisLine(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); - Reference< beans::XPropertySet > xAxisLinePropSet(xAxisLine, UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xGrid, UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xGridLine(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); + Reference< beans::XPropertySet > xGridLinePropSet(xGridLine, UNO_QUERY_THROW); // Line type drawing::LineDash aLineDash; - xAxisLinePropSet->getPropertyValue(u"LineDash"_ustr) >>= aLineDash; - OUString sAxisLineDash = + xGridLinePropSet->getPropertyValue(u"LineDash"_ustr) >>= aLineDash; + OUString sGridLineDash = OUString::number(static_cast<sal_Int32>(aLineDash.Style)) + ";" + OUString::number(aLineDash.Dots) + ";" + OUString::number(aLineDash.DotLen) + OUString::number(aLineDash.Dashes) + ";" + OUString::number(aLineDash.DashLen) + ";" + OUString::number(aLineDash.Distance); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sAxisLineDash); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sGridLineDash); // Line color - util::Color aAxisLineColor = 0; - xAxisLinePropSet->getPropertyValue(u"LineColor"_ustr) >>= aAxisLineColor; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aAxisLineColor)); + util::Color aLineColor = 0; + xGridLinePropSet->getPropertyValue(u"LineColor"_ustr) >>= aLineColor; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aLineColor)); // Line width - sal_Int32 nAxisLineWidth = 0; - xAxisLinePropSet->getPropertyValue(u"LineWidth"_ustr) >>= nAxisLineWidth; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nAxisLineWidth); + sal_Int32 nLineWidth = 0; + xGridLinePropSet->getPropertyValue(u"LineWidth"_ustr) >>= nLineWidth; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nLineWidth); } } } -CPPUNIT_TEST_FIXTURE(Chart2DumpTest, AxisLabelTest) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testDefaultFormattedAxis) { - const std::vector<OUString> aTestFiles = - { - u"default_formated_axis.odp"_ustr, - u"rotated_axis_labels.odp"_ustr, - u"formated_axis_labels.odp"_ustr, - u"percent_stacked_column_chart.odp"_ustr, - u"tdf118150.xlsx"_ustr, - u"date-categories.pptx"_ustr, - }; - - for (const OUString& sTestFile : aTestFiles) - { - setTestFileName(sTestFile, u"axislabeltest"); - loadFromFile(getTestFileName()); - uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0, 0), UNO_SET_THROW); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xShapes.is()); - - const std::vector<OUString> aAxisShapeNames = - { - u"CID/D=0:CS=0:Axis=0,0"_ustr, // X Axis - u"CID/D=0:CS=0:Axis=1,0"_ustr, // Y Axis - }; - - for (const OUString& sAxisShapeName : aAxisShapeNames) - { - uno::Reference<drawing::XShape> xXAxis = getShapeByName(xShapes, sAxisShapeName, - // Axis occurs twice in chart xshape representation so need to get the one related to labels - [](const uno::Reference<drawing::XShape>& rXShape) -> bool - { - uno::Reference<drawing::XShapes> xAxisShapes(rXShape, uno::UNO_QUERY); - CPPUNIT_ASSERT(xAxisShapes.is()); - uno::Reference<drawing::XShape> xChildShape(xAxisShapes->getByIndex(0), uno::UNO_QUERY); - uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xChildShape, uno::UNO_QUERY_THROW); - return (xShapeDescriptor->getShapeType() == "com.sun.star.drawing.TextShape"); - }); - CPPUNIT_ASSERT(xXAxis.is()); - CPPUNIT_DUMP_ASSERT_NOTE(sAxisShapeName); - - // Check label count - uno::Reference<container::XIndexAccess> xIndexAccess(xXAxis, UNO_QUERY_THROW); - sal_Int32 nAxisLabelsCount = xIndexAccess->getCount(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nAxisLabelsCount); - - // Check labels's text, positioning and font properties - for (sal_Int32 nLabelIndex = 0; nLabelIndex < nAxisLabelsCount; ++nLabelIndex) - { - // Check text - uno::Reference<text::XTextRange> xLabel(xIndexAccess->getByIndex(nLabelIndex), uno::UNO_QUERY); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(xLabel->getString()); - - // Check size and position - uno::Reference<drawing::XShape> xLabelShape(xLabel, uno::UNO_QUERY); - /*awt::Point aLabelPosition = xLabelShape->getPosition(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLabelPosition.X, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLabelPosition.Y, INT_EPS); - awt::Size aLabelSize = xLabelShape->getSize(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLabelSize.Height, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLabelSize.Width, INT_EPS);*/ - - // Check transformation - Reference< beans::XPropertySet > xPropSet(xLabelShape, UNO_QUERY_THROW); - /*drawing::HomogenMatrix3 aLabelTransformation; - xPropSet->getPropertyValue("Transformation") >>= aLabelTransformation; - CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aLabelTransformation, INT_EPS);*/ - - // Check font color and height - util::Color aLabelFontColor = 0; - xPropSet->getPropertyValue(u"CharColor"_ustr) >>= aLabelFontColor; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aLabelFontColor)); - float fLabelFontHeight = 0.0f; - xPropSet->getPropertyValue(u"CharHeight"_ustr) >>= fLabelFontHeight; - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(fLabelFontHeight, 1E-12); - } - } - } + testAxisGeometry(u"default_formated_axis.odp"_ustr); } -CPPUNIT_TEST_FIXTURE(Chart2DumpTest, ColumnBarChartTest) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testAxisSpecialPositioning) { - const std::vector<OUString> aTestFiles = - { - u"normal_column_chart.ods"_ustr, - u"stacked_column_chart.ods"_ustr, - u"percent_stacked_column_chart.ods"_ustr, - u"column_chart_small_spacing.ods"_ustr, - u"normal_bar_chart.ods"_ustr, - u"stacked_bar_chart.ods"_ustr, - u"percent_stacked_bar_chart.ods"_ustr, - }; - - for (const OUString& sTestFile : aTestFiles) - { - setTestFileName(sTestFile, u"columnbarcharttest"); - loadFromFile(getTestFileName()); - uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromSheet(0), UNO_QUERY_THROW); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xShapes.is()); - - uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); - Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); - CPPUNIT_ASSERT(xChartType.is()); - std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); - size_t nSeriesCount = aDataSeriesYValues.size(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nSeriesCount); - - for (size_t nSeries = 0; nSeries < nSeriesCount; ++nSeries) - { - uno::Reference<drawing::XShape> xSeriesColumnsOrBars = getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=" + OUString::number(nSeries)); - CPPUNIT_ASSERT(xSeriesColumnsOrBars.is()); - CPPUNIT_DUMP_ASSERT_NOTE("Series " + OUString::number(nSeries) + " ColumnsOrBars"); - - // Check column/bar count in the series - uno::Reference<container::XIndexAccess> xIndexAccess(xSeriesColumnsOrBars, UNO_QUERY_THROW); - sal_Int32 nColumnOrBarCountInSeries = xIndexAccess->getCount(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nColumnOrBarCountInSeries); - - // Check column/bar fill style and color - Reference< beans::XPropertySet > xColumnOrBarPropSet(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); - drawing::FillStyle aSeriesColumnOrBarFillStyle; - xColumnOrBarPropSet->getPropertyValue(UNO_NAME_FILLSTYLE) >>= aSeriesColumnOrBarFillStyle; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aSeriesColumnOrBarFillStyle)); - util::Color aSeriesColumnOrBarFillColor = 0; - xColumnOrBarPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aSeriesColumnOrBarFillColor; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aSeriesColumnOrBarFillColor)); - - for (sal_Int32 nColumnOrBar = 0; nColumnOrBar < nColumnOrBarCountInSeries; ++nColumnOrBar) - { - uno::Reference<drawing::XShape> xColumnOrBar(xIndexAccess->getByIndex(nColumnOrBar), UNO_QUERY_THROW); - uno::Reference<container::XNamed> xNamedShape(xIndexAccess->getByIndex(nColumnOrBar), uno::UNO_QUERY); - CPPUNIT_DUMP_ASSERT_NOTE(xNamedShape->getName()); + testAxisGeometry(u"axis_special_positioning.odp"_ustr); +} - // Check size and position - awt::Point aColumnOrBarPosition = xColumnOrBar->getPosition(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aColumnOrBarPosition.X, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aColumnOrBarPosition.Y, INT_EPS); - awt::Size aColumnOrBarSize = xColumnOrBar->getSize(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aColumnOrBarSize.Height, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aColumnOrBarSize.Width, INT_EPS); +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testFormattedAxisLines) +{ + testAxisGeometry(u"formated_axis_lines.odp"_ustr); +} - // Check transformation - Reference< beans::XPropertySet > xPropSet(xColumnOrBar, UNO_QUERY_THROW); - drawing::HomogenMatrix3 aColumnOrBarTransformation; - xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aColumnOrBarTransformation; - CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aColumnOrBarTransformation, INT_EPS); - } - } - } +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testRotatedAxisGeometry) +{ + testAxisGeometry(u"rotated_axis_labels.odp"_ustr); } -CPPUNIT_TEST_FIXTURE(Chart2DumpTest, ChartWallTest) +void Chart2DumpTest::testAxisGeometry(const OUString& rTestFile) { - const std::vector<OUString> aTestFiles = + setTestFileName(rTestFile, u"axisgeometrytest"); + loadFromFile(getTestFileName()); + uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0, 0), UNO_SET_THROW); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapes.is()); + + const std::vector<OUString> aAxisShapeNames = { - u"chartwall_auto_adjust_with_titles.ods"_ustr, - u"chartwall_auto_adjust_without_titles.ods"_ustr, - u"chartwall_custom_positioning.ods"_ustr + u"CID/D=0:CS=0:Axis=0,0"_ustr, // X Axis + u"CID/D=0:CS=0:Axis=1,0"_ustr, // Y Axis }; - for (const OUString& sTestFile : aTestFiles) + for (const OUString& sAxisShapeName : aAxisShapeNames) { - setTestFileName(sTestFile, u"chartwalltest"); - loadFromFile(getTestFileName()); - uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0, 0), UNO_SET_THROW); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xShapes.is()); - - uno::Reference<drawing::XShape> xChartWall = getShapeByName(xShapes, u"CID/DiagramWall="_ustr); - CPPUNIT_ASSERT(xChartWall.is()); + uno::Reference<drawing::XShape> xXAxis = getShapeByName(xShapes, sAxisShapeName); + CPPUNIT_ASSERT(xXAxis.is()); + CPPUNIT_DUMP_ASSERT_NOTE(sAxisShapeName); // Check position and size - /*awt::Point aChartWallPosition = xChartWall->getPosition(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aChartWallPosition.X, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aChartWallPosition.Y, INT_EPS); - awt::Size aChartWallSize = xChartWall->getSize(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aChartWallSize.Height, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aChartWallSize.Width, INT_EPS);*/ + awt::Point aAxisPosition = xXAxis->getPosition(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAxisPosition.X, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAxisPosition.Y, INT_EPS); + awt::Size aAxisSize = xXAxis->getSize(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAxisSize.Height, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAxisSize.Width, INT_EPS); // Check transformation - Reference< beans::XPropertySet > xPropSet(xChartWall, UNO_QUERY_THROW); - /*drawing::HomogenMatrix3 aChartWallTransformation; - xPropSet->getPropertyValue("Transformation") >>= aChartWallTransformation; - CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aChartWallTransformation, INT_EPS);*/ - - // Check fill properties - drawing::FillStyle aChartWallFillStyle; - xPropSet->getPropertyValue(UNO_NAME_FILLSTYLE) >>= aChartWallFillStyle; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aChartWallFillStyle)); - util::Color aChartWallFillColor = 0; - xPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aChartWallFillColor; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aChartWallFillColor)); + Reference< beans::XPropertySet > xPropSet(xXAxis, UNO_QUERY_THROW); + drawing::HomogenMatrix3 aAxisTransformation; + xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aAxisTransformation; + CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aAxisTransformation, INT_EPS); // Check line properties + uno::Reference<container::XIndexAccess> xIndexAccess(xXAxis, UNO_QUERY_THROW); + sal_Int32 nAxisGeometriesCount = xIndexAccess->getCount(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nAxisGeometriesCount); + uno::Reference<drawing::XShape> xAxisLine(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); + Reference< beans::XPropertySet > xAxisLinePropSet(xAxisLine, UNO_QUERY_THROW); // Line type drawing::LineDash aLineDash; - xPropSet->getPropertyValue(u"LineDash"_ustr) >>= aLineDash; - OUString sChartWallLineDash = + xAxisLinePropSet->getPropertyValue(u"LineDash"_ustr) >>= aLineDash; + OUString sAxisLineDash = OUString::number(static_cast<sal_Int32>(aLineDash.Style)) + ";" + OUString::number(aLineDash.Dots) + ";" + OUString::number(aLineDash.DotLen) + OUString::number(aLineDash.Dashes) + ";" + OUString::number(aLineDash.DashLen) + ";" + OUString::number(aLineDash.Distance); - CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sChartWallLineDash); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sAxisLineDash); // Line color - util::Color aChartWallLineColor = 0; - xPropSet->getPropertyValue(u"LineColor"_ustr) >>= aChartWallLineColor; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aChartWallLineColor)); + util::Color aAxisLineColor = 0; + xAxisLinePropSet->getPropertyValue(u"LineColor"_ustr) >>= aAxisLineColor; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aAxisLineColor)); // Line width - sal_Int32 nChartWallLineWidth = 0; - xPropSet->getPropertyValue(u"LineWidth"_ustr) >>= nChartWallLineWidth; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nChartWallLineWidth); + sal_Int32 nAxisLineWidth = 0; + xAxisLinePropSet->getPropertyValue(u"LineWidth"_ustr) >>= nAxisLineWidth; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nAxisLineWidth); } } -CPPUNIT_TEST_FIXTURE(Chart2DumpTest, PieChartTest) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testDefaultFormattedAxisLabel) +{ + testAxisLabel(u"default_formated_axis.odp"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testRotatedAxisLabels) +{ + testAxisLabel(u"rotated_axis_labels.odp"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testFormattedAxisLabels) +{ + testAxisLabel(u"formated_axis_labels.odp"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testAxisPercentStackedColumnChart) +{ + testAxisLabel(u"percent_stacked_column_chart.odp"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testTdf118150) +{ + testAxisLabel(u"tdf118150.xlsx"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testDateCategories) +{ + testAxisLabel(u"date-categories.pptx"_ustr); +} + +void Chart2DumpTest::testAxisLabel(const OUString& rTestFile) { - const std::vector<OUString> aTestFiles = + setTestFileName(rTestFile, u"axislabeltest"); + loadFromFile(getTestFileName()); + uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0, 0), UNO_SET_THROW); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapes.is()); + + const std::vector<OUString> aAxisShapeNames = { - u"normal_pie_chart.ods"_ustr, - u"rotated_pie_chart.ods"_ustr, - u"exploded_pie_chart.ods"_ustr, - u"donut_chart.ods"_ustr, - u"pie_chart_many_slices.ods"_ustr, + u"CID/D=0:CS=0:Axis=0,0"_ustr, // X Axis + u"CID/D=0:CS=0:Axis=1,0"_ustr, // Y Axis }; - for (const OUString& sTestFile : aTestFiles) + for (const OUString& sAxisShapeName : aAxisShapeNames) { - setTestFileName(sTestFile, u"piecharttest"); - loadFromFile(getTestFileName()); - uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromSheet(0), UNO_QUERY_THROW); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xShapes.is()); - - uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); - Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); - CPPUNIT_ASSERT(xChartType.is()); - - std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); - size_t nSeriesCount = aDataSeriesYValues.size(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nSeriesCount); - - for (size_t nSeries = 0; nSeries < nSeriesCount; ++nSeries) - { - uno::Reference<drawing::XShape> xSeriesSlices = getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=" + OUString::number(nSeries)); - if (!xSeriesSlices.is()) - break; // Normal pie chart displays only one series - CPPUNIT_DUMP_ASSERT_NOTE("Series " + OUString::number(nSeries) + " slices"); - - // Check slice count in the series - uno::Reference<container::XIndexAccess> xIndexAccess(xSeriesSlices, UNO_QUERY_THROW); - sal_Int32 nSlicesCountInSeries = xIndexAccess->getCount(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nSlicesCountInSeries); - - // Check slices properties - for (sal_Int32 nSlice = 0; nSlice < nSlicesCountInSeries; ++nSlice) + uno::Reference<drawing::XShape> xXAxis = getShapeByName(xShapes, sAxisShapeName, + // Axis occurs twice in chart xshape representation so need to get the one related to labels + [](const uno::Reference<drawing::XShape>& rXShape) -> bool { - uno::Reference<drawing::XShape> xSlice(xIndexAccess->getByIndex(nSlice), UNO_QUERY_THROW); - uno::Reference<container::XNamed> xNamedShape(xIndexAccess->getByIndex(nSlice), uno::UNO_QUERY); - OUString sName = xNamedShape->getName(); - CPPUNIT_DUMP_ASSERT_NOTE(sName.copy(sName.lastIndexOf("/D=0"))); + uno::Reference<drawing::XShapes> xAxisShapes(rXShape, uno::UNO_QUERY); + CPPUNIT_ASSERT(xAxisShapes.is()); + uno::Reference<drawing::XShape> xChildShape(xAxisShapes->getByIndex(0), uno::UNO_QUERY); + uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor(xChildShape, uno::UNO_QUERY_THROW); + return (xShapeDescriptor->getShapeType() == "com.sun.star.drawing.TextShape"); + }); + CPPUNIT_ASSERT(xXAxis.is()); + CPPUNIT_DUMP_ASSERT_NOTE(sAxisShapeName); + + // Check label count + uno::Reference<container::XIndexAccess> xIndexAccess(xXAxis, UNO_QUERY_THROW); + sal_Int32 nAxisLabelsCount = xIndexAccess->getCount(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nAxisLabelsCount); + + // Check labels's text, positioning and font properties + for (sal_Int32 nLabelIndex = 0; nLabelIndex < nAxisLabelsCount; ++nLabelIndex) + { + // Check text + uno::Reference<text::XTextRange> xLabel(xIndexAccess->getByIndex(nLabelIndex), uno::UNO_QUERY); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(xLabel->getString()); - // Check size and position - awt::Point aSlicePosition = xSlice->getPosition(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aSlicePosition.X, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aSlicePosition.Y, INT_EPS); - awt::Size aSliceSize = xSlice->getSize(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aSliceSize.Height, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aSliceSize.Width, INT_EPS); + // Check size and position + uno::Reference<drawing::XShape> xLabelShape(xLabel, uno::UNO_QUERY); + /*awt::Point aLabelPosition = xLabelShape->getPosition(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLabelPosition.X, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLabelPosition.Y, INT_EPS); + awt::Size aLabelSize = xLabelShape->getSize(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLabelSize.Height, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLabelSize.Width, INT_EPS);*/ - // Check transformation - Reference< beans::XPropertySet > xPropSet(xSlice, UNO_QUERY_THROW); - drawing::HomogenMatrix3 aSliceTransformation; - xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aSliceTransformation; - CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aSliceTransformation, INT_EPS); - - // Check slice fill style and color - drawing::FillStyle aSliceFillStyle; - xPropSet->getPropertyValue(UNO_NAME_FILLSTYLE) >>= aSliceFillStyle; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aSliceFillStyle)); - util::Color aSliceFillColor = 0; - xPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aSliceFillColor; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aSliceFillColor)); - } + // Check transformation + Reference< beans::XPropertySet > xPropSet(xLabelShape, UNO_QUERY_THROW); + /*drawing::HomogenMatrix3 aLabelTransformation; + xPropSet->getPropertyValue("Transformation") >>= aLabelTransformation; + CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aLabelTransformation, INT_EPS);*/ + + // Check font color and height + util::Color aLabelFontColor = 0; + xPropSet->getPropertyValue(u"CharColor"_ustr) >>= aLabelFontColor; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aLabelFontColor)); + float fLabelFontHeight = 0.0f; + xPropSet->getPropertyValue(u"CharHeight"_ustr) >>= fLabelFontHeight; + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(fLabelFontHeight, 1E-12); } } } -CPPUNIT_TEST_FIXTURE(Chart2DumpTest, AreaChartTest) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testNormalColumnChart) { - const std::vector<OUString> aTestFiles = - { - u"normal_area_chart.ods"_ustr, - u"stacked_area_chart.ods"_ustr, - u"percent_stacked_area_chart.ods"_ustr - }; + testColumnBar(u"normal_column_chart.ods"_ustr); +} - for (const OUString& sTestFile : aTestFiles) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testStackedColumnChart) +{ + testColumnBar(u"stacked_column_chart.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testPercentStackedColumnChart) +{ + testColumnBar(u"percent_stacked_column_chart.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testColumnChartSmallSpacing) +{ + testColumnBar(u"column_chart_small_spacing.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testNormalBarChart) +{ + testColumnBar(u"normal_bar_chart.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testStackedBarChart) +{ + testColumnBar(u"stacked_bar_chart.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testPercentStackedBarChart) +{ + testColumnBar(u"percent_stacked_bar_chart.ods"_ustr); +} + +void Chart2DumpTest::testColumnBar(const OUString& rTestFile) +{ + setTestFileName(rTestFile, u"columnbarcharttest"); + loadFromFile(getTestFileName()); + uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromSheet(0), UNO_QUERY_THROW); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapes.is()); + + uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); + Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); + CPPUNIT_ASSERT(xChartType.is()); + std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); + size_t nSeriesCount = aDataSeriesYValues.size(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nSeriesCount); + + for (size_t nSeries = 0; nSeries < nSeriesCount; ++nSeries) { - setTestFileName(sTestFile, u"areacharttest"); - loadFromFile(getTestFileName()); - uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromSheet(0), UNO_QUERY_THROW); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xShapes.is()); - - uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); - Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); - CPPUNIT_ASSERT(xChartType.is()); - - std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); - size_t nSeriesCount = aDataSeriesYValues.size(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nSeriesCount); - - for (size_t nSeries = 0; nSeries < nSeriesCount; ++nSeries) + uno::Reference<drawing::XShape> xSeriesColumnsOrBars = getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=" + OUString::number(nSeries)); + CPPUNIT_ASSERT(xSeriesColumnsOrBars.is()); + CPPUNIT_DUMP_ASSERT_NOTE("Series " + OUString::number(nSeries) + " ColumnsOrBars"); + + // Check column/bar count in the series + uno::Reference<container::XIndexAccess> xIndexAccess(xSeriesColumnsOrBars, UNO_QUERY_THROW); + sal_Int32 nColumnOrBarCountInSeries = xIndexAccess->getCount(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nColumnOrBarCountInSeries); + + // Check column/bar fill style and color + Reference< beans::XPropertySet > xColumnOrBarPropSet(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); + drawing::FillStyle aSeriesColumnOrBarFillStyle; + xColumnOrBarPropSet->getPropertyValue(UNO_NAME_FILLSTYLE) >>= aSeriesColumnOrBarFillStyle; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aSeriesColumnOrBarFillStyle)); + util::Color aSeriesColumnOrBarFillColor = 0; + xColumnOrBarPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aSeriesColumnOrBarFillColor; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aSeriesColumnOrBarFillColor)); + + for (sal_Int32 nColumnOrBar = 0; nColumnOrBar < nColumnOrBarCountInSeries; ++nColumnOrBar) { - uno::Reference<drawing::XShape> xSeries = getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=" + OUString::number(nSeries)); - CPPUNIT_ASSERT(xSeries.is()); - CPPUNIT_DUMP_ASSERT_NOTE("Series " + OUString::number(nSeries)); + uno::Reference<drawing::XShape> xColumnOrBar(xIndexAccess->getByIndex(nColumnOrBar), UNO_QUERY_THROW); + uno::Reference<container::XNamed> xNamedShape(xIndexAccess->getByIndex(nColumnOrBar), uno::UNO_QUERY); + CPPUNIT_DUMP_ASSERT_NOTE(xNamedShape->getName()); + + // Check size and position + awt::Point aColumnOrBarPosition = xColumnOrBar->getPosition(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aColumnOrBarPosition.X, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aColumnOrBarPosition.Y, INT_EPS); + awt::Size aColumnOrBarSize = xColumnOrBar->getSize(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aColumnOrBarSize.Height, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aColumnOrBarSize.Width, INT_EPS); + + // Check transformation + Reference< beans::XPropertySet > xPropSet(xColumnOrBar, UNO_QUERY_THROW); + drawing::HomogenMatrix3 aColumnOrBarTransformation; + xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aColumnOrBarTransformation; + CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aColumnOrBarTransformation, INT_EPS); + } + } +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testChartWallAutoAdjustWithTittles) +{ + testChartWall(u"chartwall_auto_adjust_with_titles.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testChartWallAutoAdjustWithoutTittles) +{ + testChartWall(u"chartwall_auto_adjust_without_titles.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testChartWallCustomPositioning) +{ + testChartWall(u"chartwall_custom_positioning.ods"_ustr); +} + +void Chart2DumpTest::testChartWall(const OUString& rTestFile) +{ + setTestFileName(rTestFile, u"chartwalltest"); + loadFromFile(getTestFileName()); + uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0, 0), UNO_SET_THROW); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapes.is()); + + uno::Reference<drawing::XShape> xChartWall = getShapeByName(xShapes, u"CID/DiagramWall="_ustr); + CPPUNIT_ASSERT(xChartWall.is()); + + // Check position and size + /*awt::Point aChartWallPosition = xChartWall->getPosition(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aChartWallPosition.X, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aChartWallPosition.Y, INT_EPS); + awt::Size aChartWallSize = xChartWall->getSize(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aChartWallSize.Height, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aChartWallSize.Width, INT_EPS);*/ + + // Check transformation + Reference< beans::XPropertySet > xPropSet(xChartWall, UNO_QUERY_THROW); + /*drawing::HomogenMatrix3 aChartWallTransformation; + xPropSet->getPropertyValue("Transformation") >>= aChartWallTransformation; + CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aChartWallTransformation, INT_EPS);*/ + + // Check fill properties + drawing::FillStyle aChartWallFillStyle; + xPropSet->getPropertyValue(UNO_NAME_FILLSTYLE) >>= aChartWallFillStyle; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aChartWallFillStyle)); + util::Color aChartWallFillColor = 0; + xPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aChartWallFillColor; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aChartWallFillColor)); + + // Check line properties + // Line type + drawing::LineDash aLineDash; + xPropSet->getPropertyValue(u"LineDash"_ustr) >>= aLineDash; + OUString sChartWallLineDash = + OUString::number(static_cast<sal_Int32>(aLineDash.Style)) + ";" + OUString::number(aLineDash.Dots) + ";" + OUString::number(aLineDash.DotLen) + + OUString::number(aLineDash.Dashes) + ";" + OUString::number(aLineDash.DashLen) + ";" + OUString::number(aLineDash.Distance); + CPPUNIT_DUMP_ASSERT_STRINGS_EQUAL(sChartWallLineDash); + // Line color + util::Color aChartWallLineColor = 0; + xPropSet->getPropertyValue(u"LineColor"_ustr) >>= aChartWallLineColor; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aChartWallLineColor)); + // Line width + sal_Int32 nChartWallLineWidth = 0; + xPropSet->getPropertyValue(u"LineWidth"_ustr) >>= nChartWallLineWidth; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nChartWallLineWidth); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testNormalPieChart) +{ + testPieChart(u"normal_pie_chart.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testRotatedPieChart) +{ + testPieChart(u"rotated_pie_chart.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testExplodedPieChart) +{ + testPieChart(u"exploded_pie_chart.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testDonutChart) +{ + testPieChart(u"donut_chart.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testPieChartManySlices) +{ + testPieChart(u"pie_chart_many_slices.ods"_ustr); +} + +void Chart2DumpTest::testPieChart(const OUString& rTestFile) +{ + setTestFileName(rTestFile, u"piecharttest"); + loadFromFile(getTestFileName()); + uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromSheet(0), UNO_QUERY_THROW); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapes.is()); + + uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); + Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); + CPPUNIT_ASSERT(xChartType.is()); - // One area for one series - uno::Reference<container::XIndexAccess> xIndexAccess(xSeries, UNO_QUERY_THROW); - uno::Reference<container::XIndexAccess> xIndexAccess2(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); // Why this second group shape is here? - uno::Reference<drawing::XShape> xArea(xIndexAccess2->getByIndex(0), UNO_QUERY_THROW); + std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); + size_t nSeriesCount = aDataSeriesYValues.size(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nSeriesCount); + + for (size_t nSeries = 0; nSeries < nSeriesCount; ++nSeries) + { + uno::Reference<drawing::XShape> xSeriesSlices = getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=" + OUString::number(nSeries)); + if (!xSeriesSlices.is()) + break; // Normal pie chart displays only one series + CPPUNIT_DUMP_ASSERT_NOTE("Series " + OUString::number(nSeries) + " slices"); + + // Check slice count in the series + uno::Reference<container::XIndexAccess> xIndexAccess(xSeriesSlices, UNO_QUERY_THROW); + sal_Int32 nSlicesCountInSeries = xIndexAccess->getCount(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nSlicesCountInSeries); + + // Check slices properties + for (sal_Int32 nSlice = 0; nSlice < nSlicesCountInSeries; ++nSlice) + { + uno::Reference<drawing::XShape> xSlice(xIndexAccess->getByIndex(nSlice), UNO_QUERY_THROW); + uno::Reference<container::XNamed> xNamedShape(xIndexAccess->getByIndex(nSlice), uno::UNO_QUERY); + OUString sName = xNamedShape->getName(); + CPPUNIT_DUMP_ASSERT_NOTE(sName.copy(sName.lastIndexOf("/D=0"))); // Check size and position - awt::Point aAreaPosition = xArea->getPosition(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAreaPosition.X, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAreaPosition.Y, INT_EPS); - awt::Size aAreaSize = xArea->getSize(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAreaSize.Height, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAreaSize.Width, INT_EPS); + awt::Point aSlicePosition = xSlice->getPosition(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aSlicePosition.X, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aSlicePosition.Y, INT_EPS); + awt::Size aSliceSize = xSlice->getSize(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aSliceSize.Height, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aSliceSize.Width, INT_EPS); // Check transformation - Reference< beans::XPropertySet > xPropSet(xArea, UNO_QUERY_THROW); - drawing::HomogenMatrix3 aAreaTransformation; - xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aAreaTransformation; - CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aAreaTransformation, INT_EPS); - - // Check area fill style and color - drawing::FillStyle aAreaFillStyle; - xPropSet->getPropertyValue(UNO_NAME_FILLSTYLE) >>= aAreaFillStyle; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aAreaFillStyle)); - util::Color aAreaFillColor = 0; - xPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aAreaFillColor; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aAreaFillColor)); + Reference< beans::XPropertySet > xPropSet(xSlice, UNO_QUERY_THROW); + drawing::HomogenMatrix3 aSliceTransformation; + xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aSliceTransformation; + CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aSliceTransformation, INT_EPS); + + // Check slice fill style and color + drawing::FillStyle aSliceFillStyle; + xPropSet->getPropertyValue(UNO_NAME_FILLSTYLE) >>= aSliceFillStyle; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aSliceFillStyle)); + util::Color aSliceFillColor = 0; + xPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aSliceFillColor; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aSliceFillColor)); } } } +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testNormalAreaChart) +{ + testAreaChart(u"normal_area_chart.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testStackedAreaChart) +{ + testAreaChart(u"stacked_area_chart.ods"_ustr); +} -CPPUNIT_TEST_FIXTURE(Chart2DumpTest, PointLineChartTest) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testPercentStackedAreaChart) { - const std::vector<OUString> aTestFiles = + testAreaChart(u"percent_stacked_area_chart.ods"_ustr); +} + +void Chart2DumpTest::testAreaChart(const OUString& rTestFile) +{ + setTestFileName(rTestFile, u"areacharttest"); + loadFromFile(getTestFileName()); + uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromSheet(0), UNO_QUERY_THROW); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapes.is()); + + uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); + Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); + CPPUNIT_ASSERT(xChartType.is()); + + std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); + size_t nSeriesCount = aDataSeriesYValues.size(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nSeriesCount); + + for (size_t nSeries = 0; nSeries < nSeriesCount; ++nSeries) { - u"normal_line_chart_lines_only.ods"_ustr, - u"normal_line_chart_points_only.ods"_ustr, - u"normal_line_chart_lines_and_points.ods"_ustr, - u"stacked_line_chart_lines_only.ods"_ustr, - u"stacked_line_chart_points_only.ods"_ustr, - u"stacked_line_chart_lines_and_points.ods"_ustr, - u"percent_stacked_line_chart_lines_only.ods"_ustr, - u"percent_stacked_line_chart_points_only.ods"_ustr, - u"percent_stacked_line_chart_lines_and_points.ods"_ustr, - u"scatter_chart_points_only.ods"_ustr, - u"scatter_chart_lines_only.ods"_ustr, - u"scatter_chart_lines_and_points.ods"_ustr, - }; + uno::Reference<drawing::XShape> xSeries = getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=" + OUString::number(nSeries)); + CPPUNIT_ASSERT(xSeries.is()); + CPPUNIT_DUMP_ASSERT_NOTE("Series " + OUString::number(nSeries)); + + // One area for one series + uno::Reference<container::XIndexAccess> xIndexAccess(xSeries, UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess2(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); // Why this second group shape is here? + uno::Reference<drawing::XShape> xArea(xIndexAccess2->getByIndex(0), UNO_QUERY_THROW); + + // Check size and position + awt::Point aAreaPosition = xArea->getPosition(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAreaPosition.X, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAreaPosition.Y, INT_EPS); + awt::Size aAreaSize = xArea->getSize(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAreaSize.Height, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aAreaSize.Width, INT_EPS); + + // Check transformation + Reference< beans::XPropertySet > xPropSet(xArea, UNO_QUERY_THROW); + drawing::HomogenMatrix3 aAreaTransformation; + xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aAreaTransformation; + CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aAreaTransformation, INT_EPS); + + // Check area fill style and color + drawing::FillStyle aAreaFillStyle; + xPropSet->getPropertyValue(UNO_NAME_FILLSTYLE) >>= aAreaFillStyle; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aAreaFillStyle)); + util::Color aAreaFillColor = 0; + xPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aAreaFillColor; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aAreaFillColor)); + } +} + + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testNormalLineChartLinesOnly) +{ + testPointLineChart(u"normal_line_chart_lines_only.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testNormalLineChartPointsOnly) +{ + testPointLineChart(u"normal_line_chart_points_only.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testNormalLineChartLinesAndPoints) +{ + testPointLineChart(u"normal_line_chart_lines_and_points.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testStackedLineChartLinesOnly) +{ + testPointLineChart(u"stacked_line_chart_lines_only.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testStackedLineChartPointsOnly) +{ + testPointLineChart(u"stacked_line_chart_points_only.ods"_ustr); +} - for (const OUString& sTestFile : aTestFiles) +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testStackedLineChartLinesAndPoints) +{ + testPointLineChart(u"stacked_line_chart_lines_and_points.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testPercentStackedLineChartLinesOnly) +{ + testPointLineChart(u"percent_stacked_line_chart_lines_only.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testPercentStackedLineChartPointsOnly) +{ + testPointLineChart(u"percent_stacked_line_chart_points_only.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testPercentStackedLineChartLinesAndPoints) +{ + testPointLineChart(u"percent_stacked_line_chart_lines_and_points.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testScatterChartPointsOnly) +{ + testPointLineChart(u"scatter_chart_points_only.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testScatterChartLinesOnly) +{ + testPointLineChart(u"scatter_chart_lines_only.ods"_ustr); +} + +CPPUNIT_TEST_FIXTURE(Chart2DumpTest, testScatterChartLinesAndPoints) +{ + testPointLineChart(u"scatter_chart_lines_and_points.ods"_ustr); +} + +void Chart2DumpTest::testPointLineChart(const OUString& rTestFile) +{ + setTestFileName(rTestFile, u"pointlinecharttest"); + loadFromFile(getTestFileName()); + uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromSheet(0), UNO_QUERY_THROW); + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapes.is()); + + uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); + Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); + CPPUNIT_ASSERT(xChartType.is()); + + std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); + size_t nSeriesCount = aDataSeriesYValues.size(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nSeriesCount); + + for (size_t nSeries = 0; nSeries < nSeriesCount; ++nSeries) { - setTestFileName(sTestFile, u"pointlinecharttest"); - loadFromFile(getTestFileName()); - uno::Reference< chart::XChartDocument > xChartDoc(getChartDocFromSheet(0), UNO_QUERY_THROW); - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); - uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); - uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xShapes.is()); - - uno::Reference< chart2::XChartDocument > xChartDoc2(xChartDoc, UNO_QUERY_THROW); - Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc2, 0); - CPPUNIT_ASSERT(xChartType.is()); - - std::vector<std::vector<double> > aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); - size_t nSeriesCount = aDataSeriesYValues.size(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nSeriesCount); - - for (size_t nSeries = 0; nSeries < nSeriesCount; ++nSeries) + uno::Reference<drawing::XShape> xSeries = getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=" + OUString::number(nSeries)); + CPPUNIT_ASSERT(xSeries.is()); + CPPUNIT_DUMP_ASSERT_NOTE("Series " + OUString::number(nSeries)); + + uno::Reference<container::XIndexAccess> xIndexAccess(xSeries, UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess2(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xLine(xIndexAccess2->getByIndex(0), UNO_QUERY_THROW); + Reference< beans::XPropertySet > xPropSet(xLine, UNO_QUERY_THROW); + + // Check whether we have line + drawing::LineStyle aSeriesLineStyle; + xPropSet->getPropertyValue(UNO_NAME_LINESTYLE) >>= aSeriesLineStyle; + if (aSeriesLineStyle != drawing::LineStyle_NONE) { - uno::Reference<drawing::XShape> xSeries = getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=" + OUString::number(nSeries)); - CPPUNIT_ASSERT(xSeries.is()); - CPPUNIT_DUMP_ASSERT_NOTE("Series " + OUString::number(nSeries)); - - uno::Reference<container::XIndexAccess> xIndexAccess(xSeries, UNO_QUERY_THROW); - uno::Reference<container::XIndexAccess> xIndexAccess2(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); - uno::Reference<drawing::XShape> xLine(xIndexAccess2->getByIndex(0), UNO_QUERY_THROW); - Reference< beans::XPropertySet > xPropSet(xLine, UNO_QUERY_THROW); - - // Check whether we have line - drawing::LineStyle aSeriesLineStyle; - xPropSet->getPropertyValue(UNO_NAME_LINESTYLE) >>= aSeriesLineStyle; - if (aSeriesLineStyle != drawing::LineStyle_NONE) - { - CPPUNIT_DUMP_ASSERT_NOTE(u"Lines are displayed"_ustr); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aSeriesLineStyle)); - - // Check line shape geometry - awt::Point aLinePosition = xLine->getPosition(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLinePosition.X, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLinePosition.Y, INT_EPS); - awt::Size aLineSize = xLine->getSize(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLineSize.Height, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLineSize.Width, INT_EPS); - CPPUNIT_ASSERT(xPropSet.is()); - drawing::HomogenMatrix3 aLineTransformation; - xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aLineTransformation; - CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aLineTransformation, INT_EPS); - } + CPPUNIT_DUMP_ASSERT_NOTE(u"Lines are displayed"_ustr); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aSeriesLineStyle)); + + // Check line shape geometry + awt::Point aLinePosition = xLine->getPosition(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLinePosition.X, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLinePosition.Y, INT_EPS); + awt::Size aLineSize = xLine->getSize(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLineSize.Height, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aLineSize.Width, INT_EPS); + CPPUNIT_ASSERT(xPropSet.is()); + drawing::HomogenMatrix3 aLineTransformation; + xPropSet->getPropertyValue(u"Transformation"_ustr) >>= aLineTransformation; + CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aLineTransformation, INT_EPS); + } - // Check points of series - if (xIndexAccess->getCount() >= 2) + // Check points of series + if (xIndexAccess->getCount() >= 2) + { + CPPUNIT_DUMP_ASSERT_NOTE(u"Points are displayed"_ustr); + uno::Reference<container::XIndexAccess> xPointsOfSeries(xIndexAccess->getByIndex(1), UNO_QUERY_THROW); + sal_Int32 nPointCountInSeries = xPointsOfSeries->getCount(); + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nPointCountInSeries); + for (sal_Int32 nPoint = 0; nPoint < nPointCountInSeries; ++nPoint) { - CPPUNIT_DUMP_ASSERT_NOTE(u"Points are displayed"_ustr); - uno::Reference<container::XIndexAccess> xPointsOfSeries(xIndexAccess->getByIndex(1), UNO_QUERY_THROW); - sal_Int32 nPointCountInSeries = xPointsOfSeries->getCount(); - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(nPointCountInSeries); - for (sal_Int32 nPoint = 0; nPoint < nPointCountInSeries; ++nPoint) - { - uno::Reference<container::XIndexAccess> XPointContainer ( - getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=" + OUString::number(nSeries) + ":Point=" + OUString::number(nPoint)), UNO_QUERY_THROW); - uno::Reference<drawing::XShape> XPoint(XPointContainer->getByIndex(0), UNO_QUERY_THROW); - uno::Reference<container::XNamed> xNamedShape(XPointContainer, uno::UNO_QUERY); - CPPUNIT_DUMP_ASSERT_NOTE(xNamedShape->getName()); - - // Check size and position - awt::Point aPointPosition = XPoint->getPosition(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aPointPosition.X, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aPointPosition.Y, INT_EPS); - awt::Size aPointSize = XPoint->getSize(); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aPointSize.Height, INT_EPS); - CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aPointSize.Width, INT_EPS); - - // Check transformation - Reference< beans::XPropertySet > xPointPropSet(XPoint, UNO_QUERY_THROW); - drawing::HomogenMatrix3 aPointTransformation; - xPointPropSet->getPropertyValue(u"Transformation"_ustr) >>= aPointTransformation; - CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aPointTransformation, INT_EPS); - - // Check fill style and color - drawing::FillStyle aPointFillStyle; - xPointPropSet->getPropertyValue(UNO_NAME_FILLSTYLE) >>= aPointFillStyle; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aPointFillStyle)); - util::Color aPointFillColor = 0; - xPointPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aPointFillColor; - CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aPointFillColor)); - } + uno::Reference<container::XIndexAccess> XPointContainer ( + getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=" + OUString::number(nSeries) + ":Point=" + OUString::number(nPoint)), UNO_QUERY_THROW); + uno::Reference<drawing::XShape> XPoint(XPointContainer->getByIndex(0), UNO_QUERY_THROW); + uno::Reference<container::XNamed> xNamedShape(XPointContainer, uno::UNO_QUERY); + CPPUNIT_DUMP_ASSERT_NOTE(xNamedShape->getName()); + + // Check size and position + awt::Point aPointPosition = XPoint->getPosition(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aPointPosition.X, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aPointPosition.Y, INT_EPS); + awt::Size aPointSize = XPoint->getSize(); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aPointSize.Height, INT_EPS); + CPPUNIT_DUMP_ASSERT_DOUBLES_EQUAL(aPointSize.Width, INT_EPS); + + // Check transformation + Reference< beans::XPropertySet > xPointPropSet(XPoint, UNO_QUERY_THROW); + drawing::HomogenMatrix3 aPointTransformation; + xPointPropSet->getPropertyValue(u"Transformation"_ustr) >>= aPointTransformation; + CPPUNIT_DUMP_ASSERT_TRANSFORMATIONS_EQUAL(aPointTransformation, INT_EPS); + + // Check fill style and color + drawing::FillStyle aPointFillStyle; + xPointPropSet->getPropertyValue(UNO_NAME_FILLSTYLE) >>= aPointFillStyle; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aPointFillStyle)); + util::Color aPointFillColor = 0; + xPointPropSet->getPropertyValue(UNO_NAME_FILLCOLOR) >>= aPointFillColor; + CPPUNIT_DUMP_ASSERT_NUMBERS_EQUAL(static_cast<sal_Int32>(aPointFillColor)); } } }
