diff options
Diffstat (limited to 'chart2/qa/extras/chart2import2.cxx')
-rw-r--r-- | chart2/qa/extras/chart2import2.cxx | 360 |
1 files changed, 194 insertions, 166 deletions
diff --git a/chart2/qa/extras/chart2import2.cxx b/chart2/qa/extras/chart2import2.cxx index f84254c30c2a..dc9a2cddae46 100644 --- a/chart2/qa/extras/chart2import2.cxx +++ b/chart2/qa/extras/chart2import2.cxx @@ -22,88 +22,15 @@ class Chart2ImportTest2 : public ChartTest { public: - void testTdf114179(); - void testTdf124243(); - void testTdf127393(); - void testTdf128733(); - void testTdf128432(); - void testTdf128627(); - void testTdf128634(); - void testTdf130657(); - void testDeletedDataLabel(); - void testDataPointInheritedColorDOCX(); - void testExternalStrRefsXLSX(); - void testSourceNumberFormatComplexCategoriesXLS(); - void testSimpleCategoryAxis(); - void testMultilevelCategoryAxis(); - void testXaxisValues(); - void testTdf123504(); - void testTdf122765(); - void testTdf123206CustomLabelField(); - void testTdf125444PercentageCustomLabel(); - void testDataPointLabelCustomPos(); - void testTdf130032(); - void testTdf134978(); - void testTdf119138MissingAutoTitleDeleted(); - void testStockChartShiftedCategoryPosition(); - void testTdf133376(); - void testTdf134225(); - void testTdf136105(); - void testTdf91250(); - void testTdf134111(); - void testTdf136752(); - void testTdf137505(); - void testTdf137734(); - void testTdf137874(); - void testTdfCustomShapePos(); - void testTdf121281(); - void testTdf139658(); - - CPPUNIT_TEST_SUITE(Chart2ImportTest2); - - CPPUNIT_TEST(testTdf114179); - CPPUNIT_TEST(testTdf124243); - CPPUNIT_TEST(testTdf127393); - CPPUNIT_TEST(testTdf128733); - CPPUNIT_TEST(testTdf128432); - CPPUNIT_TEST(testTdf128627); - CPPUNIT_TEST(testTdf128634); - CPPUNIT_TEST(testTdf130657); - CPPUNIT_TEST(testDeletedDataLabel); - CPPUNIT_TEST(testDataPointInheritedColorDOCX); - CPPUNIT_TEST(testExternalStrRefsXLSX); - CPPUNIT_TEST(testSourceNumberFormatComplexCategoriesXLS); - CPPUNIT_TEST(testSimpleCategoryAxis); - CPPUNIT_TEST(testMultilevelCategoryAxis); - CPPUNIT_TEST(testXaxisValues); - CPPUNIT_TEST(testTdf123504); - CPPUNIT_TEST(testTdf122765); - CPPUNIT_TEST(testTdf123206CustomLabelField); - CPPUNIT_TEST(testTdf125444PercentageCustomLabel); - CPPUNIT_TEST(testDataPointLabelCustomPos); - CPPUNIT_TEST(testTdf130032); - CPPUNIT_TEST(testTdf134978); - CPPUNIT_TEST(testTdf119138MissingAutoTitleDeleted); - CPPUNIT_TEST(testStockChartShiftedCategoryPosition); - CPPUNIT_TEST(testTdf133376); - CPPUNIT_TEST(testTdf134225); - CPPUNIT_TEST(testTdf136105); - CPPUNIT_TEST(testTdf91250); - CPPUNIT_TEST(testTdf134111); - CPPUNIT_TEST(testTdf136752); - CPPUNIT_TEST(testTdf137505); - CPPUNIT_TEST(testTdf137734); - CPPUNIT_TEST(testTdf137874); - CPPUNIT_TEST(testTdfCustomShapePos); - CPPUNIT_TEST(testTdf121281); - CPPUNIT_TEST(testTdf139658); - - CPPUNIT_TEST_SUITE_END(); + Chart2ImportTest2() + : ChartTest("/chart2/qa/extras/data/") + { + } }; -void Chart2ImportTest2::testTdf114179() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf114179) { - load(u"/chart2/qa/extras/data/docx/", "testTdf114179.docx"); + loadFromFile(u"docx/testTdf114179.docx"); uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); CPPUNIT_ASSERT(xChartDoc.is()); css::uno::Reference<chart2::XDiagram> xDiagram; @@ -115,9 +42,9 @@ void Chart2ImportTest2::testTdf114179() CPPUNIT_ASSERT(aSize.Height > 0); } -void Chart2ImportTest2::testTdf124243() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf124243) { - load(u"/chart2/qa/extras/data/docx/", "tdf124243.docx"); + loadFromFile(u"docx/tdf124243.docx"); uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); @@ -132,9 +59,9 @@ void Chart2ImportTest2::testTdf124243() CPPUNIT_ASSERT(!bShow); } -void Chart2ImportTest2::testTdf127393() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf127393) { - load(u"/chart2/qa/extras/data/pptx/", "tdf127393.pptx"); + loadFromFile(u"pptx/tdf127393.pptx"); // 1st chart Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); @@ -159,9 +86,9 @@ void Chart2ImportTest2::testTdf127393() CPPUNIT_ASSERT(!aScaleData2.ShiftedCategoryPosition); } -void Chart2ImportTest2::testTdf128733() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf128733) { - load(u"/chart2/qa/extras/data/odt/", "tdf128733.odt"); + loadFromFile(u"odt/tdf128733.odt"); Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); CPPUNIT_ASSERT(xChartDoc.is()); @@ -174,9 +101,9 @@ void Chart2ImportTest2::testTdf128733() CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); } -void Chart2ImportTest2::testTdf128432() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf128432) { - load(u"/chart2/qa/extras/data/ods/", "tdf128432.ods"); + loadFromFile(u"ods/tdf128432.ods"); uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); CPPUNIT_ASSERT(xChartDoc.is()); @@ -189,9 +116,9 @@ void Chart2ImportTest2::testTdf128432() CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); } -void Chart2ImportTest2::testTdf128627() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf128627) { - load(u"/chart2/qa/extras/data/xlsx/", "tdf128627.xlsx"); + loadFromFile(u"xlsx/tdf128627.xlsx"); // Test ShiftedCategoryPosition for Radar Chart uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); @@ -204,9 +131,9 @@ void Chart2ImportTest2::testTdf128627() CPPUNIT_ASSERT(!aScaleData.ShiftedCategoryPosition); } -void Chart2ImportTest2::testTdf128634() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf128634) { - load(u"/chart2/qa/extras/data/xlsx/", "tdf128634.xlsx"); + loadFromFile(u"xlsx/tdf128634.xlsx"); // Test ShiftedCategoryPosition for 3D Charts uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); @@ -219,9 +146,9 @@ void Chart2ImportTest2::testTdf128634() CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); } -void Chart2ImportTest2::testTdf130657() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf130657) { - load(u"/chart2/qa/extras/data/xlsx/", "tdf130657.xlsx"); + loadFromFile(u"xlsx/tdf130657.xlsx"); // Test ShiftedCategoryPosition for charts which is not contain a "crossbetween" OOXML tag. uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); @@ -248,10 +175,10 @@ void checkDataLabelProperties(const Reference<chart2::XDataSeries>& xDataSeries, } } -void Chart2ImportTest2::testDeletedDataLabel() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testDeletedDataLabel) { - load(u"/chart2/qa/extras/data/xlsx/", "deleted_data_labels.xlsx"); - uno::Reference<chart2::XChartDocument> xChartDoc(getChartCompFromSheet(0, mxComponent), + loadFromFile(u"xlsx/deleted_data_labels.xlsx"); + uno::Reference<chart2::XChartDocument> xChartDoc(getChartCompFromSheet(0, 0, mxComponent), UNO_QUERY_THROW); Reference<chart2::XDataSeries> xDataSeries0 = getDataSeriesFromDoc(xChartDoc, 0); CPPUNIT_ASSERT(xDataSeries0.is()); @@ -265,9 +192,9 @@ void Chart2ImportTest2::testDeletedDataLabel() checkDataLabelProperties(xDataSeries1, 2, false); } -void Chart2ImportTest2::testDataPointInheritedColorDOCX() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testDataPointInheritedColorDOCX) { - load(u"/chart2/qa/extras/data/docx/", "data_point_inherited_color.docx"); + loadFromFile(u"docx/data_point_inherited_color.docx"); uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); CPPUNIT_ASSERT(xChartDoc.is()); css::uno::Reference<chart2::XDiagram> xDiagram(xChartDoc->getFirstDiagram(), UNO_SET_THROW); @@ -280,10 +207,10 @@ void Chart2ImportTest2::testDataPointInheritedColorDOCX() CPPUNIT_ASSERT_EQUAL(sal_Int32(16776960), nColor); } -void Chart2ImportTest2::testExternalStrRefsXLSX() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testExternalStrRefsXLSX) { - load(u"/chart2/qa/extras/data/xlsx/", "external_str_ref.xlsx"); - uno::Reference<chart2::XChartDocument> xChartDoc(getChartCompFromSheet(0, mxComponent), + loadFromFile(u"xlsx/external_str_ref.xlsx"); + uno::Reference<chart2::XChartDocument> xChartDoc(getChartCompFromSheet(0, 0, mxComponent), UNO_QUERY_THROW); CPPUNIT_ASSERT(xChartDoc.is()); @@ -294,10 +221,10 @@ void Chart2ImportTest2::testExternalStrRefsXLSX() CPPUNIT_ASSERT_EQUAL(OUString("test2"), aValues[1].get<OUString>()); } -void Chart2ImportTest2::testSourceNumberFormatComplexCategoriesXLS() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testSourceNumberFormatComplexCategoriesXLS) { - load(u"/chart2/qa/extras/data/xls/", "source_number_format_axis.xls"); - uno::Reference<chart2::XChartDocument> xChartDoc(getChartCompFromSheet(0, mxComponent), + loadFromFile(u"xls/source_number_format_axis.xls"); + uno::Reference<chart2::XChartDocument> xChartDoc(getChartCompFromSheet(0, 0, mxComponent), UNO_QUERY_THROW); CPPUNIT_ASSERT(xChartDoc.is()); @@ -307,9 +234,9 @@ void Chart2ImportTest2::testSourceNumberFormatComplexCategoriesXLS() CPPUNIT_ASSERT(nNumberFormat != 0); } -void Chart2ImportTest2::testSimpleCategoryAxis() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testSimpleCategoryAxis) { - load(u"/chart2/qa/extras/data/docx/", "testSimpleCategoryAxis.docx"); + loadFromFile(u"docx/testSimpleCategoryAxis.docx"); uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); CPPUNIT_ASSERT(xChartDoc.is()); @@ -335,9 +262,9 @@ void Chart2ImportTest2::testSimpleCategoryAxis() CPPUNIT_ASSERT(aCategories[3][0].endsWith("ria 4")); } -void Chart2ImportTest2::testMultilevelCategoryAxis() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testMultilevelCategoryAxis) { - load(u"/chart2/qa/extras/data/docx/", "testMultilevelCategoryAxis.docx"); + loadFromFile(u"docx/testMultilevelCategoryAxis.docx"); uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); CPPUNIT_ASSERT(xChartDoc.is()); @@ -364,9 +291,9 @@ void Chart2ImportTest2::testMultilevelCategoryAxis() CPPUNIT_ASSERT_EQUAL(OUString("Categoria 4"), aCategories[3][1]); } -void Chart2ImportTest2::testXaxisValues() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testXaxisValues) { - load(u"/chart2/qa/extras/data/docx/", "tdf124083.docx"); + loadFromFile(u"docx/tdf124083.docx"); uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); CPPUNIT_ASSERT(xChartDoc.is()); @@ -381,9 +308,9 @@ void Chart2ImportTest2::testXaxisValues() CPPUNIT_ASSERT(std::isnan(*static_cast<const double*>(xSequence[4].getValue()))); } -void Chart2ImportTest2::testTdf123504() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf123504) { - load(u"/chart2/qa/extras/data/ods/", "pie_chart_100_and_0.ods"); + loadFromFile(u"ods/pie_chart_100_and_0.ods"); Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), UNO_QUERY_THROW); @@ -408,14 +335,14 @@ void Chart2ImportTest2::testTdf123504() CPPUNIT_ASSERT_GREATER(sal_Int32(3000), aSlicePosition.X); CPPUNIT_ASSERT_GREATER(sal_Int32(150), aSlicePosition.Y); awt::Size aSliceSize = xSlice->getSize(); - CPPUNIT_ASSERT_GREATER(sal_Int32(8500), aSliceSize.Height); - CPPUNIT_ASSERT_GREATER(sal_Int32(8500), aSliceSize.Width); + CPPUNIT_ASSERT_DOUBLES_EQUAL(8300.0, aSliceSize.Height, 10); + CPPUNIT_ASSERT_DOUBLES_EQUAL(8300.0, aSliceSize.Width, 10); } -void Chart2ImportTest2::testTdf122765() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf122765) { // The horizontal position of the slices was wrong. - load(u"/chart2/qa/extras/data/pptx/", "tdf122765.pptx"); + loadFromFile(u"pptx/tdf122765.pptx"); Reference<chart::XChartDocument> xChartDoc = getChartDocFromDrawImpress(0, 0); Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); @@ -433,14 +360,14 @@ void Chart2ImportTest2::testTdf122765() CPPUNIT_ASSERT_GREATER(sal_Int32(7000), aSlicePosition.X); } -void Chart2ImportTest2::testTdf123206CustomLabelField() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf123206CustomLabelField) { // File contains the deprecated "custom-label-field" attribute of the // "data-point" element. It should be interpreted and stored as a data point // property. - uno::Reference<chart2::XChartDocument> xChartDoc( - getChartDocFromImpress(u"/chart2/qa/extras/data/odp/", "tdf123206.odp"), - uno::UNO_QUERY_THROW); + loadFromFile(u"odp/tdf123206.odp"); + uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), + uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); CPPUNIT_ASSERT(xChartDoc.is()); Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); @@ -452,9 +379,9 @@ void Chart2ImportTest2::testTdf123206CustomLabelField() CPPUNIT_ASSERT_EQUAL(OUString("Kiskacsa"), aLabelFields[0]->getString()); } -void Chart2ImportTest2::testTdf125444PercentageCustomLabel() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf125444PercentageCustomLabel) { - load(u"/chart2/qa/extras/data/pptx/", "tdf125444.pptx"); + loadFromFile(u"pptx/tdf125444.pptx"); // 1st chart Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); @@ -472,10 +399,10 @@ void Chart2ImportTest2::testTdf125444PercentageCustomLabel() aLabelFields[2]->getFieldType()); } -void Chart2ImportTest2::testDataPointLabelCustomPos() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testDataPointLabelCustomPos) { // test CustomLabelPosition on Bar chart - load(u"/chart2/qa/extras/data/xlsx/", "testDataPointLabelCustomPos.xlsx"); + loadFromFile(u"xlsx/testDataPointLabelCustomPos.xlsx"); uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); CPPUNIT_ASSERT(xChartDoc.is()); uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); @@ -487,18 +414,18 @@ void Chart2ImportTest2::testDataPointLabelCustomPos() chart2::RelativePosition aCustomLabelPosition; xPropertySet->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition; - CPPUNIT_ASSERT_DOUBLES_EQUAL(aCustomLabelPosition.Primary, -0.14621409921671025, 1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(aCustomLabelPosition.Secondary, -5.2887961029923464E-2, 1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.14621409921671025, aCustomLabelPosition.Primary, 1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-5.2887961029923464E-2, aCustomLabelPosition.Secondary, 1e-7); sal_Int32 aPlacement; xPropertySet->getPropertyValue("LabelPlacement") >>= aPlacement; CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::OUTSIDE, aPlacement); } -void Chart2ImportTest2::testTdf130032() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf130032) { // test CustomLabelPosition on Line chart - load(u"/chart2/qa/extras/data/xlsx/", "testTdf130032.xlsx"); + loadFromFile(u"xlsx/testTdf130032.xlsx"); uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); CPPUNIT_ASSERT(xChartDoc.is()); uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); @@ -510,18 +437,18 @@ void Chart2ImportTest2::testTdf130032() chart2::RelativePosition aCustomLabelPosition; xPropertySet->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition; - CPPUNIT_ASSERT_DOUBLES_EQUAL(aCustomLabelPosition.Primary, -0.0438333333333334, 1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(aCustomLabelPosition.Secondary, 0.086794050743657, 1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.0438333333333334, aCustomLabelPosition.Primary, 1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.086794050743657, aCustomLabelPosition.Secondary, 1e-7); sal_Int32 aPlacement; xPropertySet->getPropertyValue("LabelPlacement") >>= aPlacement; CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::RIGHT, aPlacement); } -void Chart2ImportTest2::testTdf134978() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf134978) { // test CustomLabelPosition on Pie chart - load(u"/chart2/qa/extras/data/xlsx/", "tdf134978.xlsx"); + loadFromFile(u"xlsx/tdf134978.xlsx"); uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); CPPUNIT_ASSERT(xChartDoc.is()); uno::Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); @@ -537,9 +464,9 @@ void Chart2ImportTest2::testTdf134978() CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.25635352872557599, aCustomLabelPosition.Secondary, 1e-7); } -void Chart2ImportTest2::testTdf119138MissingAutoTitleDeleted() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf119138MissingAutoTitleDeleted) { - load(u"/chart2/qa/extras/data/xlsx/", "tdf119138-missing-autotitledeleted.xlsx"); + loadFromFile(u"xlsx/tdf119138-missing-autotitledeleted.xlsx"); Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); @@ -549,9 +476,9 @@ void Chart2ImportTest2::testTdf119138MissingAutoTitleDeleted() "Missing autoTitleDeleted is implied to be True if title text is present", xTitle.is()); } -void Chart2ImportTest2::testStockChartShiftedCategoryPosition() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testStockChartShiftedCategoryPosition) { - load(u"/chart2/qa/extras/data/odt/", "stock_chart_LO_6_2.odt"); + loadFromFile(u"odt/stock_chart_LO_6_2.odt"); uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); CPPUNIT_ASSERT(xChartDoc.is()); @@ -564,14 +491,14 @@ void Chart2ImportTest2::testStockChartShiftedCategoryPosition() CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); } -void Chart2ImportTest2::testTdf133376() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf133376) { // FIXME: the DPI check should be removed when either (1) the test is fixed to work with // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin. if (!IsDefaultDPI()) return; - load(u"/chart2/qa/extras/data/xlsx/", "tdf133376.xlsx"); + loadFromFile(u"xlsx/tdf133376.xlsx"); Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), UNO_QUERY_THROW); @@ -586,13 +513,13 @@ void Chart2ImportTest2::testTdf133376() CPPUNIT_ASSERT(xDataPointLabel.is()); // Check the position of the 3rd data point label, which is out from the pie slice awt::Point aLabelPosition = xDataPointLabel->getPosition(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1082, aLabelPosition.X, 30); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5462, aLabelPosition.Y, 30); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1624, aLabelPosition.X, 30); + CPPUNIT_ASSERT_DOUBLES_EQUAL(5635, aLabelPosition.Y, 30); } -void Chart2ImportTest2::testTdf134225() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf134225) { - load(u"/chart2/qa/extras/data/xlsx/", "tdf134225.xlsx"); + loadFromFile(u"xlsx/tdf134225.xlsx"); Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), UNO_QUERY_THROW); @@ -617,19 +544,19 @@ void Chart2ImportTest2::testTdf134225() awt::Point aLabelPosition2 = xDataPointLabel2->getPosition(); // Check the distance between the position of the 1st data point label and the second one - CPPUNIT_ASSERT_DOUBLES_EQUAL(1669, sal_Int32(aLabelPosition2.X - aLabelPosition1.X), 30); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2166, sal_Int32(aLabelPosition2.Y - aLabelPosition1.Y), 30); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1493, sal_Int32(aLabelPosition2.X - aLabelPosition1.X), 30); + CPPUNIT_ASSERT_DOUBLES_EQUAL(2015, sal_Int32(aLabelPosition2.Y - aLabelPosition1.Y), 30); #endif } -void Chart2ImportTest2::testTdf136105() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf136105) { // FIXME: the DPI check should be removed when either (1) the test is fixed to work with // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin. if (!IsDefaultDPI()) return; - load(u"/chart2/qa/extras/data/xlsx/", "tdf136105.xlsx"); + loadFromFile(u"xlsx/tdf136105.xlsx"); // 1st chart with fix inner position and size { Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), @@ -666,13 +593,13 @@ void Chart2ImportTest2::testTdf136105() // Check the position of the 1st data point label, which is out from the pie slice awt::Point aLabelPosition = xDataPointLabel->getPosition(); CPPUNIT_ASSERT_DOUBLES_EQUAL(7978, aLabelPosition.X, 500); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1048, aLabelPosition.Y, 500); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1550, aLabelPosition.Y, 500); } } -void Chart2ImportTest2::testTdf91250() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf91250) { - load(u"/chart2/qa/extras/data/docx/", "tdf91250.docx"); + loadFromFile(u"docx/tdf91250.docx"); uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); CPPUNIT_ASSERT(xChartDoc.is()); Reference<chart2::XInternalDataProvider> xInternalProvider(xChartDoc->getDataProvider(), @@ -691,10 +618,10 @@ void Chart2ImportTest2::testTdf91250() CPPUNIT_ASSERT_EQUAL(OUString("8.657"), aCategories[3]); } -void Chart2ImportTest2::testTdf134111() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf134111) { // tdf134111 : To check TextBreak value is true - load(u"/chart2/qa/extras/data/docx/", "tdf134111.docx"); + loadFromFile(u"docx/tdf134111.docx"); uno::Reference<chart::XChartDocument> xChartDoc = getChartDocFromWriter(0); CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); uno::Reference<chart::XDiagram> mxDiagram(xChartDoc->getDiagram()); @@ -708,9 +635,9 @@ void Chart2ImportTest2::testTdf134111() CPPUNIT_ASSERT(bTextBreak); } -void Chart2ImportTest2::testTdf136752() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf136752) { - load(u"/chart2/qa/extras/data/xlsx/", "tdf136752.xlsx"); + loadFromFile(u"xlsx/tdf136752.xlsx"); Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), UNO_QUERY_THROW); @@ -729,9 +656,9 @@ void Chart2ImportTest2::testTdf136752() CPPUNIT_ASSERT_DOUBLES_EQUAL(1458, aLabelPosition.Y, 500); } -void Chart2ImportTest2::testTdf137505() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf137505) { - load(u"/chart2/qa/extras/data/xlsx/", "tdf137505.xlsx"); + loadFromFile(u"xlsx/tdf137505.xlsx"); Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), UNO_QUERY_THROW); @@ -749,9 +676,9 @@ void Chart2ImportTest2::testTdf137505() CPPUNIT_ASSERT_EQUAL(float(12), nFontSize); } -void Chart2ImportTest2::testTdf137734() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf137734) { - load(u"/chart2/qa/extras/data/xlsx/", "tdf137734.xlsx"); + loadFromFile(u"xlsx/tdf137734.xlsx"); Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); CPPUNIT_ASSERT(xChartDoc.is()); @@ -776,9 +703,9 @@ void Chart2ImportTest2::testTdf137734() CPPUNIT_ASSERT_EQUAL(0.0, nRotation); } -void Chart2ImportTest2::testTdf137874() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf137874) { - load(u"/chart2/qa/extras/data/xlsx/", "piechart_legend.xlsx"); + loadFromFile(u"xlsx/piechart_legend.xlsx"); Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), UNO_QUERY_THROW); Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); @@ -790,9 +717,36 @@ void Chart2ImportTest2::testTdf137874() CPPUNIT_ASSERT(xLegendEntry.is()); } -void Chart2ImportTest2::testTdfCustomShapePos() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf146463) { - load(u"/chart2/qa/extras/data/docx/", "testcustomshapepos.docx"); + loadFromFile(u"ods/tdf146463.ods"); + Reference<chart2::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent)); + Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference<chart2::XChartType> xChartType = getChartTypeFromDoc(xChartDoc, 0); + std::vector<std::vector<double>> aDataSeriesYValues + = getDataSeriesYValuesFromChartType(xChartType); + size_t nLegendEntryCount = aDataSeriesYValues.size(); + CPPUNIT_ASSERT_EQUAL(size_t(14), nLegendEntryCount); + + 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"); + if (nSeriesIndex == 0) + CPPUNIT_ASSERT_MESSAGE("Legend 0 is not visible", xLegendEntry.is()); + else + CPPUNIT_ASSERT_MESSAGE( + OString("Legend " + OString::number(nSeriesIndex) + " is visible").getStr(), + !xLegendEntry.is()); + } +} + +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdfCustomShapePos) +{ + loadFromFile(u"docx/testcustomshapepos.docx"); Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), UNO_QUERY_THROW); Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); @@ -818,9 +772,9 @@ void Chart2ImportTest2::testTdfCustomShapePos() } } -void Chart2ImportTest2::testTdf121281() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf121281) { - load(u"/chart2/qa/extras/data/xlsx/", "incorrect_label_position.xlsx"); + loadFromFile(u"xlsx/incorrect_label_position.xlsx"); Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), UNO_QUERY_THROW); Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); @@ -837,9 +791,9 @@ void Chart2ImportTest2::testTdf121281() CPPUNIT_ASSERT_GREATEREQUAL(static_cast<sal_Int32>(0), aLabelPosition.Y); } -void Chart2ImportTest2::testTdf139658() +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf139658) { - load(u"/chart2/qa/extras/data/docx/", "tdf139658.docx"); + loadFromFile(u"docx/tdf139658.docx"); uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); CPPUNIT_ASSERT(xChartDoc.is()); Reference<chart2::XInternalDataProvider> xInternalProvider(xChartDoc->getDataProvider(), @@ -857,7 +811,81 @@ void Chart2ImportTest2::testTdf139658() CPPUNIT_ASSERT_EQUAL(OUString("category\"3"), aCategories[2]); } -CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest2); +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf146066) +{ + loadFromFile(u"ods/tdf146066.ods"); + Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), + 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<drawing::XShape> xYAxisShape = getShapeByName( + xShapes, "CID/D=0:CS=0:Axis=1,0", // Y Axis + // 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(xYAxisShape.is()); + + // Check label count + uno::Reference<container::XIndexAccess> xIndexAccess(xYAxisShape, UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(8), xIndexAccess->getCount()); + + // Check text + uno::Reference<text::XTextRange> xLabel0(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("0"), xLabel0->getString()); + uno::Reference<text::XTextRange> xLabel1(xIndexAccess->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("5"), xLabel1->getString()); + uno::Reference<text::XTextRange> xLabel2(xIndexAccess->getByIndex(2), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("10"), xLabel2->getString()); + uno::Reference<text::XTextRange> xLabel3(xIndexAccess->getByIndex(3), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("15"), xLabel3->getString()); + uno::Reference<text::XTextRange> xLabel4(xIndexAccess->getByIndex(4), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("20"), xLabel4->getString()); + uno::Reference<text::XTextRange> xLabel5(xIndexAccess->getByIndex(5), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("25"), xLabel5->getString()); + uno::Reference<text::XTextRange> xLabel6(xIndexAccess->getByIndex(6), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("30"), xLabel6->getString()); + uno::Reference<text::XTextRange> xLabel7(xIndexAccess->getByIndex(7), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("35"), xLabel7->getString()); +} + +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf150434) +{ + loadFromFile(u"xlsx/tdf150434.xlsx"); + Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference<drawing::XShape> xLegend = getShapeByName(xShapes, "CID/D=0:Legend="); + CPPUNIT_ASSERT(xLegend.is()); + awt::Point aPosition = xLegend->getPosition(); + + // This failed, if the legend flowed out of the chart area. + CPPUNIT_ASSERT_GREATEREQUAL(static_cast<sal_Int32>(0), aPosition.Y); +} + +CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testChartDataTableWithMultipleLegendEntriesForOneDataSeries) +{ + loadFromFile(u"xlsx/DataTable-MultipleLegendEntriesForOneDataSeries.xlsx"); + // Loading this file caused a crash in the data table code + + Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference<drawing::XShape> xDataTableShape = getShapeByName(xShapes, "CID/D=0:DataTable="); + CPPUNIT_ASSERT(xDataTableShape.is()); +} CPPUNIT_PLUGIN_IMPLEMENT(); |