From a2f42f37a0dcc584a54aaf21d3deaf98a664fad7 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Tue, 15 Jun 2021 12:22:59 +0200 Subject: [PATCH] Split CppunitTest_chart2_import into two Change-Id: I1a9b98b9e20fd6e097bc8fd68958b7feb66991f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117236 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- chart2/CppunitTest_chart2_import.mk | 120 +--- chart2/CppunitTest_chart2_import2.mk | 14 + chart2/Module_chart2.mk | 2 + chart2/import_setup.mk | 143 +++++ chart2/qa/extras/chart2import.cxx | 807 ------------------------ chart2/qa/extras/chart2import2.cxx | 881 +++++++++++++++++++++++++++ 6 files changed, 1042 insertions(+), 925 deletions(-) create mode 100644 chart2/CppunitTest_chart2_import2.mk create mode 100644 chart2/import_setup.mk create mode 100644 chart2/qa/extras/chart2import2.cxx diff --git a/chart2/CppunitTest_chart2_import.mk b/chart2/CppunitTest_chart2_import.mk index f91d0f95d29c..d568b8855378 100644 --- a/chart2/CppunitTest_chart2_import.mk +++ b/chart2/CppunitTest_chart2_import.mk @@ -9,123 +9,7 @@ # #************************************************************************* -$(eval $(call gb_CppunitTest_CppunitTest,chart2_import)) - -$(eval $(call gb_CppunitTest_use_externals,chart2_import, \ - boost_headers \ - libxml2 \ -)) - -$(eval $(call gb_CppunitTest_add_exception_objects,chart2_import, \ - chart2/qa/extras/chart2import \ -)) - -$(eval $(call gb_CppunitTest_use_libraries,chart2_import, \ - basegfx \ - comphelper \ - cppu \ - cppuhelper \ - drawinglayer \ - editeng \ - for \ - forui \ - i18nlangtag \ - msfilter \ - vcl \ - oox \ - sal \ - salhelper \ - sax \ - sb \ - sc \ - sw \ - sd \ - sfx \ - sot \ - svl \ - svt \ - svx \ - svxcore \ - test \ - tl \ - tk \ - ucbhelper \ - unotest \ - utl \ - vbahelper \ - xo \ - sw \ -)) - -$(eval $(call gb_CppunitTest_set_include,chart2_import,\ - -I$(SRCDIR)/chart2/inc \ - $$(INCLUDE) \ -)) - -$(eval $(call gb_CppunitTest_use_sdk_api,chart2_import)) - -$(eval $(call gb_CppunitTest_use_ure,chart2_import)) -$(eval $(call gb_CppunitTest_use_vcl,chart2_import)) - -$(eval $(call gb_CppunitTest_use_components,chart2_import,\ - basic/util/sb \ - animations/source/animcore/animcore \ - chart2/source/controller/chartcontroller \ - chart2/source/chartcore \ - comphelper/util/comphelp \ - configmgr/source/configmgr \ - embeddedobj/util/embobj \ - emfio/emfio \ - eventattacher/source/evtatt \ - filter/source/config/cache/filterconfig1 \ - filter/source/odfflatxml/odfflatxml \ - filter/source/storagefilterdetect/storagefd \ - filter/source/xmlfilteradaptor/xmlfa \ - filter/source/xmlfilterdetect/xmlfd \ - forms/util/frm \ - framework/util/fwk \ - i18npool/util/i18npool \ - linguistic/source/lng \ - oox/util/oox \ - package/source/xstor/xstor \ - package/util/package2 \ - sax/source/expatwrap/expwrap \ - sc/util/sc \ - sc/util/scd \ - sc/util/scfilt \ - sw/util/sw \ - sw/util/swd \ - sw/util/msword \ - sd/util/sd \ - sd/util/sdfilt \ - sd/util/sdd \ - $(call gb_Helper_optional,SCRIPTING, \ - sc/util/vbaobj) \ - scaddins/source/analysis/analysis \ - scaddins/source/datefunc/date \ - scripting/source/basprov/basprov \ - scripting/util/scriptframe \ - sfx2/util/sfx \ - sot/util/sot \ - svl/source/fsstor/fsstorage \ - svl/util/svl \ - svtools/util/svt \ - svx/util/svx \ - svx/util/svxcore \ - toolkit/util/tk \ - vcl/vcl.common \ - ucb/source/core/ucb1 \ - ucb/source/ucp/file/ucpfile1 \ - ucb/source/ucp/tdoc/ucptdoc1 \ - unotools/util/utl \ - unoxml/source/rdf/unordf \ - unoxml/source/service/unoxml \ - uui/util/uui \ - writerfilter/util/writerfilter \ - xmloff/util/xo \ - xmlscript/util/xmlscript \ -)) - -$(eval $(call gb_CppunitTest_use_configuration,chart2_import)) +# empty second argument (i.e. no 1) +$(eval $(call chart2_import_test,)) # vim: set noet sw=4 ts=4: diff --git a/chart2/CppunitTest_chart2_import2.mk b/chart2/CppunitTest_chart2_import2.mk new file mode 100644 index 000000000000..0e4a967de557 --- /dev/null +++ b/chart2/CppunitTest_chart2_import2.mk @@ -0,0 +1,14 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call chart2_import_test,2)) + +# vim: set noet sw=4 ts=4: diff --git a/chart2/Module_chart2.mk b/chart2/Module_chart2.mk index 9bcdd7b363e1..94cba43344fa 100644 --- a/chart2/Module_chart2.mk +++ b/chart2/Module_chart2.mk @@ -7,6 +7,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # +include $(SRCDIR)/chart2/import_setup.mk include $(SRCDIR)/chart2/export_setup.mk $(eval $(call gb_Module_Module,chart2)) @@ -30,6 +31,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,chart2,\ CppunitTest_chart2_export \ CppunitTest_chart2_export2 \ CppunitTest_chart2_import \ + CppunitTest_chart2_import2 \ CppunitTest_chart2_trendcalculators \ CppunitTest_chart2_dump \ CppunitTest_chart2_pivot_chart_test \ diff --git a/chart2/import_setup.mk b/chart2/import_setup.mk new file mode 100644 index 000000000000..16647f5f9a0c --- /dev/null +++ b/chart2/import_setup.mk @@ -0,0 +1,143 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +# template for import tests +define chart2_import$(1)_test + +$(eval $(call gb_CppunitTest_CppunitTest,chart2_import$(1))) + +$(eval $(call gb_CppunitTest_use_externals,chart2_import$(1), \ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_add_exception_objects,chart2_import$(1), \ + chart2/qa/extras/chart2import$(1) \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,chart2_import$(1), \ + $(call gb_Helper_optional,AVMEDIA,avmedia) \ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + for \ + forui \ + i18nlangtag \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sc \ + sw \ + sd \ + sfx \ + sot \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + tk \ + ucbhelper \ + unotest \ + utl \ + vbahelper \ + vcl \ + xo \ +)) + +$(eval $(call gb_CppunitTest_set_include,chart2_import$(1),\ + -I$(SRCDIR)/chart2/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,chart2_import$(1))) + +$(eval $(call gb_CppunitTest_use_ure,chart2_import$(1))) +$(eval $(call gb_CppunitTest_use_vcl,chart2_import$(1))) + +$(eval $(call gb_CppunitTest_use_components,chart2_import$(1),\ + basic/util/sb \ + animations/source/animcore/animcore \ + chart2/source/controller/chartcontroller \ + chart2/source/chartcore \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + embeddedobj/util/embobj \ + emfio/emfio \ + eventattacher/source/evtatt \ + filter/source/config/cache/filterconfig1 \ + filter/source/odfflatxml/odfflatxml \ + filter/source/storagefilterdetect/storagefd \ + filter/source/xmlfilteradaptor/xmlfa \ + filter/source/xmlfilterdetect/xmlfd \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + linguistic/source/lng \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + sc/util/sc \ + sc/util/scd \ + sc/util/scfilt \ + sw/util/sw \ + sw/util/swd \ + sw/util/msword \ + sd/util/sd \ + sd/util/sdfilt \ + sd/util/sdd \ + $(call gb_Helper_optional,SCRIPTING, \ + sc/util/vbaobj) \ + scaddins/source/analysis/analysis \ + scaddins/source/datefunc/date \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + svl/util/svl \ + svtools/util/svt \ + svx/util/svx \ + svx/util/svxcore \ + toolkit/util/tk \ + vcl/vcl.common \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ + uui/util/uui \ + writerfilter/util/writerfilter \ + xmloff/util/xo \ + xmlscript/util/xmlscript \ +)) + +$(eval $(call gb_CppunitTest_use_uiconfigs,chart2_import$(1), \ + modules/swriter \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,chart2_import$(1))) + +$(call gb_CppunitTest_get_target,chart2_import$(1)): $(call gb_Package_get_target,postprocess_images) + +endef + +# vim: set noet sw=4 ts=4: diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 0c142a4e7f97..41d55297a336 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -139,43 +139,6 @@ public: void testTdf121205(); - 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(Chart2ImportTest); CPPUNIT_TEST(Fdo60083); CPPUNIT_TEST(testSteppedLines); @@ -263,47 +226,7 @@ public: CPPUNIT_TEST(testTdf121205); - 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(); - -private: - }; // error bar import @@ -2187,736 +2110,6 @@ void Chart2ImportTest::testTdf121205() CPPUNIT_ASSERT_EQUAL(OUString("Firstline\nSecondline\nThirdline"), aTitle); } -void Chart2ImportTest::testTdf114179() -{ - load( u"/chart2/qa/extras/data/docx/", "testTdf114179.docx" ); - uno::Reference< chart2::XChartDocument > xChartDoc ( getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT( xChartDoc.is() ); - css::uno::Reference xDiagram; - xDiagram.set( xChartDoc->getFirstDiagram() ); - CPPUNIT_ASSERT_MESSAGE( "There is a Diagram." , xDiagram.is() ); - awt::Size aPage = getPageSize( xChartDoc ); - awt::Size aSize = getSize( xDiagram,aPage ); - CPPUNIT_ASSERT( aSize.Width > 0); - CPPUNIT_ASSERT( aSize.Height > 0); -} - -void Chart2ImportTest::testTdf124243() -{ - load(u"/chart2/qa/extras/data/docx/", "tdf124243.docx"); - uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); - - Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); - CPPUNIT_ASSERT(xAxis.is()); - - Reference xPS(xAxis, uno::UNO_QUERY_THROW); - bool bShow = true; - // test X Axis is not visible. - bool bSuccess = xPS->getPropertyValue("Show") >>= bShow; - CPPUNIT_ASSERT(bSuccess); - CPPUNIT_ASSERT(!bShow); -} - -void Chart2ImportTest::testTdf127393() -{ - load(u"/chart2/qa/extras/data/pptx/", "tdf127393.pptx"); - - // 1st chart - Reference xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); - CPPUNIT_ASSERT(xAxis.is()); - - chart2::ScaleData aScaleData1 = xAxis->getScaleData(); - CPPUNIT_ASSERT(aScaleData1.Categories.is()); - CPPUNIT_ASSERT(aScaleData1.ShiftedCategoryPosition); - - // 2nd chart - xChartDoc.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - xAxis.set(getAxisFromDoc(xChartDoc, 0, 0, 0)); - CPPUNIT_ASSERT(xAxis.is()); - - chart2::ScaleData aScaleData2 = xAxis->getScaleData(); - CPPUNIT_ASSERT(aScaleData2.Categories.is()); - CPPUNIT_ASSERT(!aScaleData2.ShiftedCategoryPosition); -} - -void Chart2ImportTest::testTdf128733() -{ - load(u"/chart2/qa/extras/data/odt/", "tdf128733.odt"); - - Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - // test secondary X axis ShiftedCategoryPosition value - Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 1); - CPPUNIT_ASSERT(xAxis.is()); - - chart2::ScaleData aScaleData = xAxis->getScaleData(); - CPPUNIT_ASSERT(aScaleData.Categories.is()); - CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); -} - -void Chart2ImportTest::testTdf128432() -{ - load(u"/chart2/qa/extras/data/ods/", "tdf128432.ods"); - - uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - - Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); - CPPUNIT_ASSERT(xAxis.is()); - - chart2::ScaleData aScaleData = xAxis->getScaleData(); - CPPUNIT_ASSERT(aScaleData.Categories.is()); - CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); -} - -void Chart2ImportTest::testTdf128627() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf128627.xlsx"); - // Test ShiftedCategoryPosition for Radar Chart - uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); - - Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); - CPPUNIT_ASSERT(xAxis.is()); - - chart2::ScaleData aScaleData = xAxis->getScaleData(); - CPPUNIT_ASSERT(aScaleData.Categories.is()); - CPPUNIT_ASSERT(!aScaleData.ShiftedCategoryPosition); -} - -void Chart2ImportTest::testTdf128634() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf128634.xlsx"); - // Test ShiftedCategoryPosition for 3D Charts - uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); - - Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); - CPPUNIT_ASSERT(xAxis.is()); - - chart2::ScaleData aScaleData = xAxis->getScaleData(); - CPPUNIT_ASSERT(aScaleData.Categories.is()); - CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); -} - -void Chart2ImportTest::testTdf130657() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf130657.xlsx"); - // Test ShiftedCategoryPosition for charts which is not contain a "crossbetween" OOXML tag. - uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); - - Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); - CPPUNIT_ASSERT(xAxis.is()); - - chart2::ScaleData aScaleData = xAxis->getScaleData(); - CPPUNIT_ASSERT(aScaleData.Categories.is()); - CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); -} - -namespace { - -void checkDataLabelProperties(const Reference& xDataSeries, sal_Int32 nDataPointIndex, bool bValueVisible) -{ - uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(nDataPointIndex), uno::UNO_SET_THROW); - chart2::DataPointLabel aLabel; - xPropertySet->getPropertyValue("Label") >>= aLabel; - CPPUNIT_ASSERT_EQUAL(bValueVisible, static_cast(aLabel.ShowNumber)); - CPPUNIT_ASSERT_EQUAL(false, static_cast(aLabel.ShowNumberInPercent)); -} - -} - -void Chart2ImportTest::testDeletedDataLabel() -{ - load(u"/chart2/qa/extras/data/xlsx/", "deleted_data_labels.xlsx"); - uno::Reference< chart2::XChartDocument > xChartDoc( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW ); - Reference xDataSeries0 = getDataSeriesFromDoc(xChartDoc, 0); - CPPUNIT_ASSERT(xDataSeries0.is()); - checkDataLabelProperties(xDataSeries0, 0, true); - checkDataLabelProperties(xDataSeries0, 1, false); - checkDataLabelProperties(xDataSeries0, 2, true); - Reference xDataSeries1 = getDataSeriesFromDoc(xChartDoc, 1); - CPPUNIT_ASSERT(xDataSeries1.is()); - checkDataLabelProperties(xDataSeries1, 0, false); - checkDataLabelProperties(xDataSeries1, 1, false); - checkDataLabelProperties(xDataSeries1, 2, false); -} - -void Chart2ImportTest::testDataPointInheritedColorDOCX() -{ - load( u"/chart2/qa/extras/data/docx/", "data_point_inherited_color.docx" ); - uno::Reference< chart2::XChartDocument > xChartDoc ( getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT( xChartDoc.is() ); - css::uno::Reference xDiagram(xChartDoc->getFirstDiagram(), UNO_SET_THROW); - - Reference xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); - uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); - CPPUNIT_ASSERT(xPropertySet.is()); - sal_Int32 nColor = xPropertySet->getPropertyValue("FillColor").get(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(16776960), nColor); -} - -void Chart2ImportTest::testExternalStrRefsXLSX() -{ - load(u"/chart2/qa/extras/data/xlsx/", "external_str_ref.xlsx"); - uno::Reference< chart2::XChartDocument > xChartDoc( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW ); - CPPUNIT_ASSERT(xChartDoc.is()); - - Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); - chart2::ScaleData aScaleData = xAxis->getScaleData(); - css::uno::Sequence aValues = aScaleData.Categories->getValues()->getData(); - CPPUNIT_ASSERT_EQUAL(OUString("test1"), aValues[0].get()); - CPPUNIT_ASSERT_EQUAL(OUString("test2"), aValues[1].get()); -} - -void Chart2ImportTest::testSourceNumberFormatComplexCategoriesXLS() -{ - load(u"/chart2/qa/extras/data/xls/", "source_number_format_axis.xls"); - uno::Reference< chart2::XChartDocument > xChartDoc( getChartCompFromSheet( 0, mxComponent ), UNO_QUERY_THROW ); - CPPUNIT_ASSERT(xChartDoc.is()); - - Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); - chart2::ScaleData aScaleData = xAxis->getScaleData(); - sal_Int32 nNumberFormat = aScaleData.Categories->getValues()->getNumberFormatKeyByIndex(-1); - CPPUNIT_ASSERT(nNumberFormat != 0); -} - -void Chart2ImportTest::testSimpleCategoryAxis() -{ - load(u"/chart2/qa/extras/data/docx/", "testSimpleCategoryAxis.docx"); - uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - // Test the internal data. - CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider()); - - Reference xInternalProvider(xChartDoc->getDataProvider(), uno::UNO_QUERY); - CPPUNIT_ASSERT(xInternalProvider.is()); - - Reference xDescAccess(xInternalProvider, uno::UNO_QUERY); - CPPUNIT_ASSERT(xDescAccess.is()); - - // Get the category labels. - Sequence > aCategories = xDescAccess->getComplexRowDescriptions(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[0].getLength()); - CPPUNIT_ASSERT(aCategories[0][0].endsWith("ria 1")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[1].getLength()); - CPPUNIT_ASSERT(aCategories[1][0].endsWith("ria 2")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[2].getLength()); - CPPUNIT_ASSERT(aCategories[2][0].endsWith("ria 3")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[3].getLength()); - CPPUNIT_ASSERT(aCategories[3][0].endsWith("ria 4")); -} - -void Chart2ImportTest::testMultilevelCategoryAxis() -{ - load(u"/chart2/qa/extras/data/docx/", "testMultilevelCategoryAxis.docx"); - uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - // Test the internal data. - CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider()); - - Reference xInternalProvider(xChartDoc->getDataProvider(), uno::UNO_QUERY); - CPPUNIT_ASSERT(xInternalProvider.is()); - - Reference xDescAccess(xInternalProvider, uno::UNO_QUERY); - CPPUNIT_ASSERT(xDescAccess.is()); - - // Get the complex category labels. - Sequence > aCategories = xDescAccess->getComplexRowDescriptions(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aCategories.getLength()); - CPPUNIT_ASSERT_EQUAL(OUString("2011"), aCategories[0][0]); - CPPUNIT_ASSERT_EQUAL(OUString(""), aCategories[1][0]); - CPPUNIT_ASSERT_EQUAL(OUString("2012"), aCategories[2][0]); - CPPUNIT_ASSERT_EQUAL(OUString(""), aCategories[3][0]); - CPPUNIT_ASSERT_EQUAL(OUString("Categoria 1"), aCategories[0][1]); - CPPUNIT_ASSERT_EQUAL(OUString("Categoria 2"), aCategories[1][1]); - CPPUNIT_ASSERT_EQUAL(OUString("Categoria 3"), aCategories[2][1]); - CPPUNIT_ASSERT_EQUAL(OUString("Categoria 4"), aCategories[3][1]); -} - -void Chart2ImportTest::testXaxisValues() -{ - load(u"/chart2/qa/extras/data/docx/", "tdf124083.docx"); - uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - const uno::Reference< chart2::data::XDataSequence > xDataSeq = getDataSequenceFromDocByRole(xChartDoc, u"values-x"); - Sequence xSequence = xDataSeq->getData(); - // test X values - CPPUNIT_ASSERT_EQUAL(uno::Any(0.04), xSequence[0]); - CPPUNIT_ASSERT(std::isnan(*static_cast(xSequence[1].getValue()))); - CPPUNIT_ASSERT_EQUAL(uno::Any(0.16), xSequence[2]); - CPPUNIT_ASSERT_EQUAL(uno::Any(0.11), xSequence[3]); - CPPUNIT_ASSERT(std::isnan(*static_cast(xSequence[4].getValue()))); -} - -void Chart2ImportTest::testTdf123504() -{ - load(u"/chart2/qa/extras/data/ods/", "pie_chart_100_and_0.ods"); - Reference xChartDoc(getChartDocFromSheet(0, mxComponent), - UNO_QUERY_THROW); - - Reference xChartDoc2(xChartDoc, UNO_QUERY_THROW); - Reference xChartType(getChartTypeFromDoc(xChartDoc2, 0), UNO_SET_THROW); - std::vector aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); - CPPUNIT_ASSERT_EQUAL(size_t(1), aDataSeriesYValues.size()); - - Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); - Reference xSeriesSlices(getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=0"), - UNO_SET_THROW); - - Reference xIndexAccess(xSeriesSlices, UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); - Reference xSlice(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); - - // Check size and position of the only slice in the chart (100%) - // In the regressed state, it used to be 0-sized at position 0,0 - awt::Point aSlicePosition = xSlice->getPosition(); - 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); -} - -void Chart2ImportTest::testTdf122765() -{ - // The horizontal position of the slices was wrong. - load(u"/chart2/qa/extras/data/pptx/", "tdf122765.pptx"); - Reference xChartDoc = getChartDocFromDrawImpress(0, 0); - Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); - Reference xSeriesSlices(getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=0"), - UNO_SET_THROW); - - Reference xIndexAccess(xSeriesSlices, UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(sal_Int32(9), xIndexAccess->getCount()); - Reference xSlice(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); - - // Check position of the first slice, all slices move together, so enough to check only one. - // Wrong position was around 5856. - awt::Point aSlicePosition = xSlice->getPosition(); - CPPUNIT_ASSERT_GREATER(sal_Int32(7000), aSlicePosition.X); -} - -void Chart2ImportTest::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); - CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); - CPPUNIT_ASSERT(xDataSeries.is()); - Reference xDp = xDataSeries->getDataPointByIndex(1); - Sequence> aLabelFields; - CPPUNIT_ASSERT(xDp->getPropertyValue("CustomLabelFields") >>= aLabelFields); - CPPUNIT_ASSERT_EQUAL(static_cast(1), aLabelFields.getLength()); - CPPUNIT_ASSERT_EQUAL(OUString("Kiskacsa"), aLabelFields[0]->getString()); - -} - -void Chart2ImportTest::testTdf125444PercentageCustomLabel() -{ - load(u"/chart2/qa/extras/data/pptx/", "tdf125444.pptx"); - - // 1st chart - Reference xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - Reference xDp = xDataSeries->getDataPointByIndex(1); - Sequence> aLabelFields; - CPPUNIT_ASSERT(xDp->getPropertyValue("CustomLabelFields") >>= aLabelFields); - // There are three label field: a value label, a newline and a percentage label. We want - // to assert the latter. - CPPUNIT_ASSERT_EQUAL(static_cast(3), aLabelFields.getLength()); - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType_PERCENTAGE, aLabelFields[2]->getFieldType()); -} - -void Chart2ImportTest::testDataPointLabelCustomPos() -{ - // test CustomLabelPosition on Bar chart - load(u"/chart2/qa/extras/data/xlsx/", "testDataPointLabelCustomPos.xlsx"); - uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - - uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); - CPPUNIT_ASSERT(xPropertySet.is()); - - 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); - - sal_Int32 aPlacement; - xPropertySet->getPropertyValue("LabelPlacement") >>= aPlacement; - CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::OUTSIDE, aPlacement); -} - -void Chart2ImportTest::testTdf130032() -{ - // test CustomLabelPosition on Line chart - load(u"/chart2/qa/extras/data/xlsx/", "testTdf130032.xlsx"); - uno::Reference< chart2::XChartDocument > xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - - uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(1), uno::UNO_SET_THROW); - CPPUNIT_ASSERT(xPropertySet.is()); - - 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); - - sal_Int32 aPlacement; - xPropertySet->getPropertyValue("LabelPlacement") >>= aPlacement; - CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::RIGHT, aPlacement); -} - -void Chart2ImportTest::testTdf134978() -{ - // test CustomLabelPosition on Pie chart - load(u"/chart2/qa/extras/data/xlsx/", "tdf134978.xlsx"); - uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - - uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(2), - uno::UNO_SET_THROW); - CPPUNIT_ASSERT(xPropertySet.is()); - - chart2::RelativePosition aCustomLabelPosition; - xPropertySet->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition; - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.040273622047244093, aCustomLabelPosition.Primary, 1e-7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.25635352872557599, aCustomLabelPosition.Secondary, 1e-7); -} - -void Chart2ImportTest::testTdf119138MissingAutoTitleDeleted() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf119138-missing-autotitledeleted.xlsx"); - Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); - - Reference xTitled(xChartDoc, uno::UNO_QUERY_THROW); - uno::Reference xTitle = xTitled->getTitleObject(); - CPPUNIT_ASSERT_MESSAGE("Missing autoTitleDeleted is implied to be True if title text is present", xTitle.is()); -} - -void Chart2ImportTest::testStockChartShiftedCategoryPosition() -{ - load(u"/chart2/qa/extras/data/odt/", "stock_chart_LO_6_2.odt"); - - uno::Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); - CPPUNIT_ASSERT(xAxis.is()); - - chart2::ScaleData aScaleData = xAxis->getScaleData(); - CPPUNIT_ASSERT(aScaleData.Categories.is()); - CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); -} - -void Chart2ImportTest::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"); - Reference xChartDoc(getChartDocFromSheet(0, mxComponent), - UNO_QUERY_THROW); - - Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); - Reference xDataPointLabel(getShapeByName(xShapes, - "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=2"), UNO_SET_THROW); - - 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); -} - -void Chart2ImportTest::testTdf134225() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf134225.xlsx"); - Reference xChartDoc(getChartDocFromSheet(0, mxComponent), - UNO_QUERY_THROW); - - Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); - Reference xDataPointLabel1(getShapeByName(xShapes, - "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0"), UNO_SET_THROW); - CPPUNIT_ASSERT(xDataPointLabel1.is()); - - Reference xDataPointLabel2(getShapeByName(xShapes, - "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=1"), UNO_SET_THROW); - CPPUNIT_ASSERT(xDataPointLabel2.is()); - -#if defined(_WIN32) - // font is MS Comic Sans which we can only assume is available under windows - awt::Point aLabelPosition1 = xDataPointLabel1->getPosition(); - 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); -#endif -} - -void Chart2ImportTest::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"); - // 1st chart with fix inner position and size - { - Reference xChartDoc(getChartDocFromSheet(0, mxComponent), - UNO_QUERY_THROW); - - Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); - Reference xDataPointLabel(getShapeByName(xShapes, - "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0"), UNO_SET_THROW); - - CPPUNIT_ASSERT(xDataPointLabel.is()); - // 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(8797, aLabelPosition.X, 500); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1374, aLabelPosition.Y, 500); - } - // 2nd chart with auto inner position and size - { - Reference xChartDoc(getChartDocFromSheet(1, mxComponent), - UNO_QUERY_THROW); - - Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); - Reference xDataPointLabel(getShapeByName(xShapes, - "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0"), UNO_SET_THROW); - - CPPUNIT_ASSERT(xDataPointLabel.is()); - // 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); - } -} - -void Chart2ImportTest::testTdf91250() -{ - load(u"/chart2/qa/extras/data/docx/", "tdf91250.docx"); - uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xInternalProvider(xChartDoc->getDataProvider(), uno::UNO_QUERY); - CPPUNIT_ASSERT(xInternalProvider.is()); - - Reference xDescAccess(xInternalProvider, uno::UNO_QUERY); - CPPUNIT_ASSERT(xDescAccess.is()); - - // Get the category labels. - Sequence aCategories = xDescAccess->getRowDescriptions(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aCategories.getLength()); - CPPUNIT_ASSERT_EQUAL(OUString("12.3254"), aCategories[0]); - CPPUNIT_ASSERT_EQUAL(OUString("11.62315"), aCategories[1]); - CPPUNIT_ASSERT_EQUAL(OUString("9.26"), aCategories[2]); - CPPUNIT_ASSERT_EQUAL(OUString("8.657"), aCategories[3]); -} - -void Chart2ImportTest::testTdf134111() -{ - // tdf134111 : To check TextBreak value is true - load(u"/chart2/qa/extras/data/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()); - CPPUNIT_ASSERT(mxDiagram.is()); - uno::Reference< chart::XAxisXSupplier > xAxisXSupp(mxDiagram, uno::UNO_QUERY); - CPPUNIT_ASSERT(xAxisXSupp.is()); - uno::Reference< beans::XPropertySet > xAxisProp(xAxisXSupp->getXAxis()); - bool bTextBreak = false; - xAxisProp->getPropertyValue("TextBreak") >>= bTextBreak; - // Expected value of 'TextBreak' is true - CPPUNIT_ASSERT(bTextBreak); -} - -void Chart2ImportTest::testTdf136752() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf136752.xlsx"); - Reference xChartDoc(getChartDocFromSheet(0, mxComponent), - UNO_QUERY_THROW); - - Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); - Reference xDataPointLabel(getShapeByName(xShapes, - "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0"), UNO_SET_THROW); - - CPPUNIT_ASSERT(xDataPointLabel.is()); - // 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(8675, aLabelPosition.X, 500); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1458, aLabelPosition.Y, 500); -} - -void Chart2ImportTest::testTdf137505() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf137505.xlsx"); - Reference xChartDoc(getChartDocFromSheet(0, mxComponent), - UNO_QUERY_THROW); - - Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xCustomShape(xDrawPage->getByIndex(1), UNO_QUERY_THROW); - CPPUNIT_ASSERT(xCustomShape.is()); - - float nFontSize; - Reference< text::XText > xRange(xCustomShape, uno::UNO_QUERY_THROW); - Reference < text::XTextCursor > xAt = xRange->createTextCursor(); - Reference< beans::XPropertySet > xProps(xAt, UNO_QUERY); - // check the text size of custom shape, inside the chart. - CPPUNIT_ASSERT(xProps->getPropertyValue("CharHeight") >>= nFontSize); - CPPUNIT_ASSERT_EQUAL(float(12), nFontSize); -} - -void Chart2ImportTest::testTdf137734() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf137734.xlsx"); - Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); - CPPUNIT_ASSERT(xDataSeries.is()); - Reference xPropSet(xDataSeries, uno::UNO_QUERY_THROW); - uno::Any aAny = xPropSet->getPropertyValue("VaryColorsByPoint"); - bool bVaryColor = true; - CPPUNIT_ASSERT(aAny >>= bVaryColor); - CPPUNIT_ASSERT(!bVaryColor); - - // tdf#126133 Test primary X axis Rotation value - Reference xXAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); - CPPUNIT_ASSERT(xXAxis.is()); - Reference xTitled(xXAxis, uno::UNO_QUERY_THROW); - Reference xTitle = xTitled->getTitleObject(); - CPPUNIT_ASSERT(xTitle.is()); - Reference xTitlePropSet(xTitle, uno::UNO_QUERY_THROW); - uno::Any aAny2 = xTitlePropSet->getPropertyValue("TextRotation"); - double nRotation = -1; - CPPUNIT_ASSERT(aAny2 >>= nRotation); - CPPUNIT_ASSERT_EQUAL(0.0, nRotation); -} - -void Chart2ImportTest::testTdf137874() -{ - load(u"/chart2/qa/extras/data/xlsx/", "piechart_legend.xlsx"); - Reference xChartDoc(getChartDocFromSheet(0, mxComponent), - UNO_QUERY_THROW); - Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); - Reference xLegendEntry; - xLegendEntry - = getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=0:Point=0:LegendEntry=0"); - CPPUNIT_ASSERT(xLegendEntry.is()); -} - -void Chart2ImportTest::testTdfCustomShapePos() -{ - load(u"/chart2/qa/extras/data/docx/", "testcustomshapepos.docx"); - Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), UNO_QUERY_THROW); - Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - // test position and size of a custom shape within a chart, rotated by 0 degree. - { - Reference xCustomShape(xDrawPage->getByIndex(0), UNO_QUERY_THROW); - awt::Point aPosition = xCustomShape->getPosition(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8845, aPosition.X, 300); - CPPUNIT_ASSERT_DOUBLES_EQUAL(855, aPosition.Y, 300); - awt::Size aSize = xCustomShape->getSize(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4831, aSize.Width, 300); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1550, aSize.Height, 300); - } - // test position and size of a custom shape within a chart, rotated by 90 degree. - { - Reference xCustomShape(xDrawPage->getByIndex(1), UNO_QUERY_THROW); - awt::Point aPosition = xCustomShape->getPosition(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1658, aPosition.X, 300); - CPPUNIT_ASSERT_DOUBLES_EQUAL(6119, aPosition.Y, 300); - awt::Size aSize = xCustomShape->getSize(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(4165, aSize.Width, 300); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1334, aSize.Height, 300); - } -} - -void Chart2ImportTest::testTdf121281() -{ - load(u"/chart2/qa/extras/data/xlsx/", "incorrect_label_position.xlsx"); - Reference xChartDoc(getChartDocFromSheet(0, mxComponent), - UNO_QUERY_THROW); - Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); - Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); - Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); - Reference xDataPointLabel( - getShapeByName(xShapes, - "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0"), - UNO_SET_THROW); - - CPPUNIT_ASSERT(xDataPointLabel.is()); - awt::Point aLabelPosition = xDataPointLabel->getPosition(); - // This failed, if the data label flowed out of the chart area. - CPPUNIT_ASSERT_GREATEREQUAL(static_cast(0), aLabelPosition.Y); -} - -void Chart2ImportTest::testTdf139658() -{ - load(u"/chart2/qa/extras/data/docx/", "tdf139658.docx"); - uno::Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xInternalProvider(xChartDoc->getDataProvider(), - uno::UNO_QUERY); - CPPUNIT_ASSERT(xInternalProvider.is()); - - Reference xDescAccess(xInternalProvider, uno::UNO_QUERY); - CPPUNIT_ASSERT(xDescAccess.is()); - - // Get the category labels. - Sequence aCategories = xDescAccess->getRowDescriptions(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aCategories.getLength()); - CPPUNIT_ASSERT_EQUAL(OUString("category1"), aCategories[0]); - CPPUNIT_ASSERT_EQUAL(OUString("\"category2\""), aCategories[1]); - CPPUNIT_ASSERT_EQUAL(OUString("category\"3"), aCategories[2]); -} - CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/chart2import2.cxx b/chart2/qa/extras/chart2import2.cxx new file mode 100644 index 000000000000..0693a1e64184 --- /dev/null +++ b/chart2/qa/extras/chart2import2.cxx @@ -0,0 +1,881 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "charttest.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +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(); +}; + +void Chart2ImportTest2::testTdf114179() +{ + load(u"/chart2/qa/extras/data/docx/", "testTdf114179.docx"); + uno::Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + css::uno::Reference xDiagram; + xDiagram.set(xChartDoc->getFirstDiagram()); + CPPUNIT_ASSERT_MESSAGE("There is a Diagram.", xDiagram.is()); + awt::Size aPage = getPageSize(xChartDoc); + awt::Size aSize = getSize(xDiagram, aPage); + CPPUNIT_ASSERT(aSize.Width > 0); + CPPUNIT_ASSERT(aSize.Height > 0); +} + +void Chart2ImportTest2::testTdf124243() +{ + load(u"/chart2/qa/extras/data/docx/", "tdf124243.docx"); + uno::Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + + Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); + CPPUNIT_ASSERT(xAxis.is()); + + Reference xPS(xAxis, uno::UNO_QUERY_THROW); + bool bShow = true; + // test X Axis is not visible. + bool bSuccess = xPS->getPropertyValue("Show") >>= bShow; + CPPUNIT_ASSERT(bSuccess); + CPPUNIT_ASSERT(!bShow); +} + +void Chart2ImportTest2::testTdf127393() +{ + load(u"/chart2/qa/extras/data/pptx/", "tdf127393.pptx"); + + // 1st chart + Reference xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); + CPPUNIT_ASSERT(xAxis.is()); + + chart2::ScaleData aScaleData1 = xAxis->getScaleData(); + CPPUNIT_ASSERT(aScaleData1.Categories.is()); + CPPUNIT_ASSERT(aScaleData1.ShiftedCategoryPosition); + + // 2nd chart + xChartDoc.set(getChartDocFromDrawImpress(1, 0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + xAxis.set(getAxisFromDoc(xChartDoc, 0, 0, 0)); + CPPUNIT_ASSERT(xAxis.is()); + + chart2::ScaleData aScaleData2 = xAxis->getScaleData(); + CPPUNIT_ASSERT(aScaleData2.Categories.is()); + CPPUNIT_ASSERT(!aScaleData2.ShiftedCategoryPosition); +} + +void Chart2ImportTest2::testTdf128733() +{ + load(u"/chart2/qa/extras/data/odt/", "tdf128733.odt"); + + Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + // test secondary X axis ShiftedCategoryPosition value + Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 1); + CPPUNIT_ASSERT(xAxis.is()); + + chart2::ScaleData aScaleData = xAxis->getScaleData(); + CPPUNIT_ASSERT(aScaleData.Categories.is()); + CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); +} + +void Chart2ImportTest2::testTdf128432() +{ + load(u"/chart2/qa/extras/data/ods/", "tdf128432.ods"); + + uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + + Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); + CPPUNIT_ASSERT(xAxis.is()); + + chart2::ScaleData aScaleData = xAxis->getScaleData(); + CPPUNIT_ASSERT(aScaleData.Categories.is()); + CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); +} + +void Chart2ImportTest2::testTdf128627() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf128627.xlsx"); + // Test ShiftedCategoryPosition for Radar Chart + uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + + Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); + CPPUNIT_ASSERT(xAxis.is()); + + chart2::ScaleData aScaleData = xAxis->getScaleData(); + CPPUNIT_ASSERT(aScaleData.Categories.is()); + CPPUNIT_ASSERT(!aScaleData.ShiftedCategoryPosition); +} + +void Chart2ImportTest2::testTdf128634() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf128634.xlsx"); + // Test ShiftedCategoryPosition for 3D Charts + uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + + Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); + CPPUNIT_ASSERT(xAxis.is()); + + chart2::ScaleData aScaleData = xAxis->getScaleData(); + CPPUNIT_ASSERT(aScaleData.Categories.is()); + CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); +} + +void Chart2ImportTest2::testTdf130657() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf130657.xlsx"); + // Test ShiftedCategoryPosition for charts which is not contain a "crossbetween" OOXML tag. + uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + + Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); + CPPUNIT_ASSERT(xAxis.is()); + + chart2::ScaleData aScaleData = xAxis->getScaleData(); + CPPUNIT_ASSERT(aScaleData.Categories.is()); + CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); +} + +namespace +{ +void checkDataLabelProperties(const Reference& xDataSeries, + sal_Int32 nDataPointIndex, bool bValueVisible) +{ + uno::Reference xPropertySet( + xDataSeries->getDataPointByIndex(nDataPointIndex), uno::UNO_SET_THROW); + chart2::DataPointLabel aLabel; + xPropertySet->getPropertyValue("Label") >>= aLabel; + CPPUNIT_ASSERT_EQUAL(bValueVisible, static_cast(aLabel.ShowNumber)); + CPPUNIT_ASSERT_EQUAL(false, static_cast(aLabel.ShowNumberInPercent)); +} +} + +void Chart2ImportTest2::testDeletedDataLabel() +{ + load(u"/chart2/qa/extras/data/xlsx/", "deleted_data_labels.xlsx"); + uno::Reference xChartDoc(getChartCompFromSheet(0, mxComponent), + UNO_QUERY_THROW); + Reference xDataSeries0 = getDataSeriesFromDoc(xChartDoc, 0); + CPPUNIT_ASSERT(xDataSeries0.is()); + checkDataLabelProperties(xDataSeries0, 0, true); + checkDataLabelProperties(xDataSeries0, 1, false); + checkDataLabelProperties(xDataSeries0, 2, true); + Reference xDataSeries1 = getDataSeriesFromDoc(xChartDoc, 1); + CPPUNIT_ASSERT(xDataSeries1.is()); + checkDataLabelProperties(xDataSeries1, 0, false); + checkDataLabelProperties(xDataSeries1, 1, false); + checkDataLabelProperties(xDataSeries1, 2, false); +} + +void Chart2ImportTest2::testDataPointInheritedColorDOCX() +{ + load(u"/chart2/qa/extras/data/docx/", "data_point_inherited_color.docx"); + uno::Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + css::uno::Reference xDiagram(xChartDoc->getFirstDiagram(), UNO_SET_THROW); + + Reference xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); + uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(0), + uno::UNO_SET_THROW); + CPPUNIT_ASSERT(xPropertySet.is()); + sal_Int32 nColor = xPropertySet->getPropertyValue("FillColor").get(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(16776960), nColor); +} + +void Chart2ImportTest2::testExternalStrRefsXLSX() +{ + load(u"/chart2/qa/extras/data/xlsx/", "external_str_ref.xlsx"); + uno::Reference xChartDoc(getChartCompFromSheet(0, mxComponent), + UNO_QUERY_THROW); + CPPUNIT_ASSERT(xChartDoc.is()); + + Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); + chart2::ScaleData aScaleData = xAxis->getScaleData(); + css::uno::Sequence aValues = aScaleData.Categories->getValues()->getData(); + CPPUNIT_ASSERT_EQUAL(OUString("test1"), aValues[0].get()); + CPPUNIT_ASSERT_EQUAL(OUString("test2"), aValues[1].get()); +} + +void Chart2ImportTest2::testSourceNumberFormatComplexCategoriesXLS() +{ + load(u"/chart2/qa/extras/data/xls/", "source_number_format_axis.xls"); + uno::Reference xChartDoc(getChartCompFromSheet(0, mxComponent), + UNO_QUERY_THROW); + CPPUNIT_ASSERT(xChartDoc.is()); + + Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); + chart2::ScaleData aScaleData = xAxis->getScaleData(); + sal_Int32 nNumberFormat = aScaleData.Categories->getValues()->getNumberFormatKeyByIndex(-1); + CPPUNIT_ASSERT(nNumberFormat != 0); +} + +void Chart2ImportTest2::testSimpleCategoryAxis() +{ + load(u"/chart2/qa/extras/data/docx/", "testSimpleCategoryAxis.docx"); + uno::Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + // Test the internal data. + CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider()); + + Reference xInternalProvider(xChartDoc->getDataProvider(), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xInternalProvider.is()); + + Reference xDescAccess(xInternalProvider, uno::UNO_QUERY); + CPPUNIT_ASSERT(xDescAccess.is()); + + // Get the category labels. + Sequence> aCategories = xDescAccess->getComplexRowDescriptions(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[0].getLength()); + CPPUNIT_ASSERT(aCategories[0][0].endsWith("ria 1")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[1].getLength()); + CPPUNIT_ASSERT(aCategories[1][0].endsWith("ria 2")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[2].getLength()); + CPPUNIT_ASSERT(aCategories[2][0].endsWith("ria 3")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aCategories[3].getLength()); + CPPUNIT_ASSERT(aCategories[3][0].endsWith("ria 4")); +} + +void Chart2ImportTest2::testMultilevelCategoryAxis() +{ + load(u"/chart2/qa/extras/data/docx/", "testMultilevelCategoryAxis.docx"); + uno::Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + // Test the internal data. + CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider()); + + Reference xInternalProvider(xChartDoc->getDataProvider(), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xInternalProvider.is()); + + Reference xDescAccess(xInternalProvider, uno::UNO_QUERY); + CPPUNIT_ASSERT(xDescAccess.is()); + + // Get the complex category labels. + Sequence> aCategories = xDescAccess->getComplexRowDescriptions(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aCategories.getLength()); + CPPUNIT_ASSERT_EQUAL(OUString("2011"), aCategories[0][0]); + CPPUNIT_ASSERT_EQUAL(OUString(""), aCategories[1][0]); + CPPUNIT_ASSERT_EQUAL(OUString("2012"), aCategories[2][0]); + CPPUNIT_ASSERT_EQUAL(OUString(""), aCategories[3][0]); + CPPUNIT_ASSERT_EQUAL(OUString("Categoria 1"), aCategories[0][1]); + CPPUNIT_ASSERT_EQUAL(OUString("Categoria 2"), aCategories[1][1]); + CPPUNIT_ASSERT_EQUAL(OUString("Categoria 3"), aCategories[2][1]); + CPPUNIT_ASSERT_EQUAL(OUString("Categoria 4"), aCategories[3][1]); +} + +void Chart2ImportTest2::testXaxisValues() +{ + load(u"/chart2/qa/extras/data/docx/", "tdf124083.docx"); + uno::Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + const uno::Reference xDataSeq + = getDataSequenceFromDocByRole(xChartDoc, u"values-x"); + Sequence xSequence = xDataSeq->getData(); + // test X values + CPPUNIT_ASSERT_EQUAL(uno::Any(0.04), xSequence[0]); + CPPUNIT_ASSERT(std::isnan(*static_cast(xSequence[1].getValue()))); + CPPUNIT_ASSERT_EQUAL(uno::Any(0.16), xSequence[2]); + CPPUNIT_ASSERT_EQUAL(uno::Any(0.11), xSequence[3]); + CPPUNIT_ASSERT(std::isnan(*static_cast(xSequence[4].getValue()))); +} + +void Chart2ImportTest2::testTdf123504() +{ + load(u"/chart2/qa/extras/data/ods/", "pie_chart_100_and_0.ods"); + Reference xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + + Reference xChartDoc2(xChartDoc, UNO_QUERY_THROW); + Reference xChartType(getChartTypeFromDoc(xChartDoc2, 0), UNO_SET_THROW); + std::vector aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType); + CPPUNIT_ASSERT_EQUAL(size_t(1), aDataSeriesYValues.size()); + + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference xSeriesSlices(getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=0"), + UNO_SET_THROW); + + Reference xIndexAccess(xSeriesSlices, UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + Reference xSlice(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); + + // Check size and position of the only slice in the chart (100%) + // In the regressed state, it used to be 0-sized at position 0,0 + awt::Point aSlicePosition = xSlice->getPosition(); + 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); +} + +void Chart2ImportTest2::testTdf122765() +{ + // The horizontal position of the slices was wrong. + load(u"/chart2/qa/extras/data/pptx/", "tdf122765.pptx"); + Reference xChartDoc = getChartDocFromDrawImpress(0, 0); + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference xSeriesSlices(getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=0"), + UNO_SET_THROW); + + Reference xIndexAccess(xSeriesSlices, UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9), xIndexAccess->getCount()); + Reference xSlice(xIndexAccess->getByIndex(0), UNO_QUERY_THROW); + + // Check position of the first slice, all slices move together, so enough to check only one. + // Wrong position was around 5856. + awt::Point aSlicePosition = xSlice->getPosition(); + CPPUNIT_ASSERT_GREATER(sal_Int32(7000), aSlicePosition.X); +} + +void 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 xChartDoc( + getChartDocFromImpress(u"/chart2/qa/extras/data/odp/", "tdf123206.odp"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference xDp = xDataSeries->getDataPointByIndex(1); + Sequence> aLabelFields; + CPPUNIT_ASSERT(xDp->getPropertyValue("CustomLabelFields") >>= aLabelFields); + CPPUNIT_ASSERT_EQUAL(static_cast(1), aLabelFields.getLength()); + CPPUNIT_ASSERT_EQUAL(OUString("Kiskacsa"), aLabelFields[0]->getString()); +} + +void Chart2ImportTest2::testTdf125444PercentageCustomLabel() +{ + load(u"/chart2/qa/extras/data/pptx/", "tdf125444.pptx"); + + // 1st chart + Reference xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference xDp = xDataSeries->getDataPointByIndex(1); + Sequence> aLabelFields; + CPPUNIT_ASSERT(xDp->getPropertyValue("CustomLabelFields") >>= aLabelFields); + // There are three label field: a value label, a newline and a percentage label. We want + // to assert the latter. + CPPUNIT_ASSERT_EQUAL(static_cast(3), aLabelFields.getLength()); + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType_PERCENTAGE, + aLabelFields[2]->getFieldType()); +} + +void Chart2ImportTest2::testDataPointLabelCustomPos() +{ + // test CustomLabelPosition on Bar chart + load(u"/chart2/qa/extras/data/xlsx/", "testDataPointLabelCustomPos.xlsx"); + uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + + uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(0), + uno::UNO_SET_THROW); + CPPUNIT_ASSERT(xPropertySet.is()); + + 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); + + sal_Int32 aPlacement; + xPropertySet->getPropertyValue("LabelPlacement") >>= aPlacement; + CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::OUTSIDE, aPlacement); +} + +void Chart2ImportTest2::testTdf130032() +{ + // test CustomLabelPosition on Line chart + load(u"/chart2/qa/extras/data/xlsx/", "testTdf130032.xlsx"); + uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + + uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(1), + uno::UNO_SET_THROW); + CPPUNIT_ASSERT(xPropertySet.is()); + + 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); + + sal_Int32 aPlacement; + xPropertySet->getPropertyValue("LabelPlacement") >>= aPlacement; + CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::RIGHT, aPlacement); +} + +void Chart2ImportTest2::testTdf134978() +{ + // test CustomLabelPosition on Pie chart + load(u"/chart2/qa/extras/data/xlsx/", "tdf134978.xlsx"); + uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + + uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(2), + uno::UNO_SET_THROW); + CPPUNIT_ASSERT(xPropertySet.is()); + + chart2::RelativePosition aCustomLabelPosition; + xPropertySet->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition; + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.040273622047244093, aCustomLabelPosition.Primary, 1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.25635352872557599, aCustomLabelPosition.Secondary, 1e-7); +} + +void Chart2ImportTest2::testTdf119138MissingAutoTitleDeleted() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf119138-missing-autotitledeleted.xlsx"); + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + + Reference xTitled(xChartDoc, uno::UNO_QUERY_THROW); + uno::Reference xTitle = xTitled->getTitleObject(); + CPPUNIT_ASSERT_MESSAGE( + "Missing autoTitleDeleted is implied to be True if title text is present", xTitle.is()); +} + +void Chart2ImportTest2::testStockChartShiftedCategoryPosition() +{ + load(u"/chart2/qa/extras/data/odt/", "stock_chart_LO_6_2.odt"); + + uno::Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + Reference xAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); + CPPUNIT_ASSERT(xAxis.is()); + + chart2::ScaleData aScaleData = xAxis->getScaleData(); + CPPUNIT_ASSERT(aScaleData.Categories.is()); + CPPUNIT_ASSERT(aScaleData.ShiftedCategoryPosition); +} + +void 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"); + Reference xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference xDataPointLabel( + getShapeByName(xShapes, + "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=2"), + UNO_SET_THROW); + + 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); +} + +void Chart2ImportTest2::testTdf134225() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf134225.xlsx"); + Reference xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference xDataPointLabel1( + getShapeByName(xShapes, + "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0"), + UNO_SET_THROW); + CPPUNIT_ASSERT(xDataPointLabel1.is()); + + Reference xDataPointLabel2( + getShapeByName(xShapes, + "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=1"), + UNO_SET_THROW); + CPPUNIT_ASSERT(xDataPointLabel2.is()); + +#if defined(_WIN32) + // font is MS Comic Sans which we can only assume is available under windows + awt::Point aLabelPosition1 = xDataPointLabel1->getPosition(); + 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); +#endif +} + +void 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"); + // 1st chart with fix inner position and size + { + Reference xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference xDataPointLabel( + getShapeByName(xShapes, + "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0"), + UNO_SET_THROW); + + CPPUNIT_ASSERT(xDataPointLabel.is()); + // 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(8797, aLabelPosition.X, 500); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1374, aLabelPosition.Y, 500); + } + // 2nd chart with auto inner position and size + { + Reference xChartDoc(getChartDocFromSheet(1, mxComponent), + UNO_QUERY_THROW); + + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference xDataPointLabel( + getShapeByName(xShapes, + "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0"), + UNO_SET_THROW); + + CPPUNIT_ASSERT(xDataPointLabel.is()); + // 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); + } +} + +void Chart2ImportTest2::testTdf91250() +{ + load(u"/chart2/qa/extras/data/docx/", "tdf91250.docx"); + uno::Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xInternalProvider(xChartDoc->getDataProvider(), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xInternalProvider.is()); + + Reference xDescAccess(xInternalProvider, uno::UNO_QUERY); + CPPUNIT_ASSERT(xDescAccess.is()); + + // Get the category labels. + Sequence aCategories = xDescAccess->getRowDescriptions(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aCategories.getLength()); + CPPUNIT_ASSERT_EQUAL(OUString("12.3254"), aCategories[0]); + CPPUNIT_ASSERT_EQUAL(OUString("11.62315"), aCategories[1]); + CPPUNIT_ASSERT_EQUAL(OUString("9.26"), aCategories[2]); + CPPUNIT_ASSERT_EQUAL(OUString("8.657"), aCategories[3]); +} + +void Chart2ImportTest2::testTdf134111() +{ + // tdf134111 : To check TextBreak value is true + load(u"/chart2/qa/extras/data/docx/", "tdf134111.docx"); + uno::Reference xChartDoc = getChartDocFromWriter(0); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + uno::Reference mxDiagram(xChartDoc->getDiagram()); + CPPUNIT_ASSERT(mxDiagram.is()); + uno::Reference xAxisXSupp(mxDiagram, uno::UNO_QUERY); + CPPUNIT_ASSERT(xAxisXSupp.is()); + uno::Reference xAxisProp(xAxisXSupp->getXAxis()); + bool bTextBreak = false; + xAxisProp->getPropertyValue("TextBreak") >>= bTextBreak; + // Expected value of 'TextBreak' is true + CPPUNIT_ASSERT(bTextBreak); +} + +void Chart2ImportTest2::testTdf136752() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf136752.xlsx"); + Reference xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference xDataPointLabel( + getShapeByName(xShapes, + "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0"), + UNO_SET_THROW); + + CPPUNIT_ASSERT(xDataPointLabel.is()); + // 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(8675, aLabelPosition.X, 500); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1458, aLabelPosition.Y, 500); +} + +void Chart2ImportTest2::testTdf137505() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf137505.xlsx"); + Reference xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xCustomShape(xDrawPage->getByIndex(1), UNO_QUERY_THROW); + CPPUNIT_ASSERT(xCustomShape.is()); + + float nFontSize; + Reference xRange(xCustomShape, uno::UNO_QUERY_THROW); + Reference xAt = xRange->createTextCursor(); + Reference xProps(xAt, UNO_QUERY); + // check the text size of custom shape, inside the chart. + CPPUNIT_ASSERT(xProps->getPropertyValue("CharHeight") >>= nFontSize); + CPPUNIT_ASSERT_EQUAL(float(12), nFontSize); +} + +void Chart2ImportTest2::testTdf137734() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf137734.xlsx"); + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is()); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference xPropSet(xDataSeries, uno::UNO_QUERY_THROW); + uno::Any aAny = xPropSet->getPropertyValue("VaryColorsByPoint"); + bool bVaryColor = true; + CPPUNIT_ASSERT(aAny >>= bVaryColor); + CPPUNIT_ASSERT(!bVaryColor); + + // tdf#126133 Test primary X axis Rotation value + Reference xXAxis = getAxisFromDoc(xChartDoc, 0, 0, 0); + CPPUNIT_ASSERT(xXAxis.is()); + Reference xTitled(xXAxis, uno::UNO_QUERY_THROW); + Reference xTitle = xTitled->getTitleObject(); + CPPUNIT_ASSERT(xTitle.is()); + Reference xTitlePropSet(xTitle, uno::UNO_QUERY_THROW); + uno::Any aAny2 = xTitlePropSet->getPropertyValue("TextRotation"); + double nRotation = -1; + CPPUNIT_ASSERT(aAny2 >>= nRotation); + CPPUNIT_ASSERT_EQUAL(0.0, nRotation); +} + +void Chart2ImportTest2::testTdf137874() +{ + load(u"/chart2/qa/extras/data/xlsx/", "piechart_legend.xlsx"); + Reference xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference xLegendEntry; + xLegendEntry + = getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=0:Point=0:LegendEntry=0"); + CPPUNIT_ASSERT(xLegendEntry.is()); +} + +void Chart2ImportTest2::testTdfCustomShapePos() +{ + load(u"/chart2/qa/extras/data/docx/", "testcustomshapepos.docx"); + Reference xChartDoc(getChartDocFromWriter(0), UNO_QUERY_THROW); + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + // test position and size of a custom shape within a chart, rotated by 0 degree. + { + Reference xCustomShape(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + awt::Point aPosition = xCustomShape->getPosition(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(8845, aPosition.X, 300); + CPPUNIT_ASSERT_DOUBLES_EQUAL(855, aPosition.Y, 300); + awt::Size aSize = xCustomShape->getSize(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4831, aSize.Width, 300); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1550, aSize.Height, 300); + } + // test position and size of a custom shape within a chart, rotated by 90 degree. + { + Reference xCustomShape(xDrawPage->getByIndex(1), UNO_QUERY_THROW); + awt::Point aPosition = xCustomShape->getPosition(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1658, aPosition.X, 300); + CPPUNIT_ASSERT_DOUBLES_EQUAL(6119, aPosition.Y, 300); + awt::Size aSize = xCustomShape->getSize(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(4165, aSize.Width, 300); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1334, aSize.Height, 300); + } +} + +void Chart2ImportTest2::testTdf121281() +{ + load(u"/chart2/qa/extras/data/xlsx/", "incorrect_label_position.xlsx"); + Reference xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + Reference xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW); + Reference xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW); + Reference xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW); + Reference xDataPointLabel( + getShapeByName(xShapes, + "CID/MultiClick/CID/D=0:CS=0:CT=0:Series=0:DataLabels=:DataLabel=0"), + UNO_SET_THROW); + + CPPUNIT_ASSERT(xDataPointLabel.is()); + awt::Point aLabelPosition = xDataPointLabel->getPosition(); + // This failed, if the data label flowed out of the chart area. + CPPUNIT_ASSERT_GREATEREQUAL(static_cast(0), aLabelPosition.Y); +} + +void Chart2ImportTest2::testTdf139658() +{ + load(u"/chart2/qa/extras/data/docx/", "tdf139658.docx"); + uno::Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xInternalProvider(xChartDoc->getDataProvider(), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xInternalProvider.is()); + + Reference xDescAccess(xInternalProvider, uno::UNO_QUERY); + CPPUNIT_ASSERT(xDescAccess.is()); + + // Get the category labels. + Sequence aCategories = xDescAccess->getRowDescriptions(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aCategories.getLength()); + CPPUNIT_ASSERT_EQUAL(OUString("category1"), aCategories[0]); + CPPUNIT_ASSERT_EQUAL(OUString("\"category2\""), aCategories[1]); + CPPUNIT_ASSERT_EQUAL(OUString("category\"3"), aCategories[2]); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest2); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */