From 94fdd0191fe30e193aea19f365397074a816fbe6 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Wed, 9 Jun 2021 14:24:24 +0200 Subject: [PATCH] Split CppunitTest_chart2_export into two it already had 148 tests Change-Id: I83e0055bcf1449cd48a28149a6ef0b149a1d6901 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116914 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- chart2/CppunitTest_chart2_export.mk | 127 +- chart2/CppunitTest_chart2_export2.mk | 14 + chart2/Module_chart2.mk | 3 + chart2/export_setup.mk | 143 ++ chart2/qa/extras/chart2dump/chart2dump.cxx | 2 +- chart2/qa/extras/chart2export.cxx | 1231 +---------------- chart2/qa/extras/chart2export2.cxx | 1427 ++++++++++++++++++++ chart2/qa/extras/chart2geometry.cxx | 66 +- chart2/qa/extras/charttest.hxx | 61 +- chart2/qa/extras/xshape/chart2xshape.cxx | 2 +- 10 files changed, 1654 insertions(+), 1422 deletions(-) create mode 100644 chart2/CppunitTest_chart2_export2.mk create mode 100644 chart2/export_setup.mk create mode 100644 chart2/qa/extras/chart2export2.cxx diff --git a/chart2/CppunitTest_chart2_export.mk b/chart2/CppunitTest_chart2_export.mk index 29147efc03aa..df390d9b4262 100644 --- a/chart2/CppunitTest_chart2_export.mk +++ b/chart2/CppunitTest_chart2_export.mk @@ -9,130 +9,7 @@ # #************************************************************************* -$(eval $(call gb_CppunitTest_CppunitTest,chart2_export)) - -$(eval $(call gb_CppunitTest_use_externals,chart2_export, \ - boost_headers \ - libxml2 \ -)) - -$(eval $(call gb_CppunitTest_add_exception_objects,chart2_export, \ - chart2/qa/extras/chart2export \ -)) - -$(eval $(call gb_CppunitTest_use_libraries,chart2_export, \ - $(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_export,\ - -I$(SRCDIR)/chart2/inc \ - $$(INCLUDE) \ -)) - -$(eval $(call gb_CppunitTest_use_sdk_api,chart2_export)) - -$(eval $(call gb_CppunitTest_use_ure,chart2_export)) -$(eval $(call gb_CppunitTest_use_vcl,chart2_export)) - -$(eval $(call gb_CppunitTest_use_components,chart2_export,\ - 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_export, \ - modules/swriter \ -)) - -$(eval $(call gb_CppunitTest_use_configuration,chart2_export)) - -$(call gb_CppunitTest_get_target,chart2_export): $(call gb_Package_get_target,postprocess_images) +# empty second argument (i.e. no 1) +$(eval $(call chart2_export_test,)) # vim: set noet sw=4 ts=4: diff --git a/chart2/CppunitTest_chart2_export2.mk b/chart2/CppunitTest_chart2_export2.mk new file mode 100644 index 000000000000..0584cbfc9931 --- /dev/null +++ b/chart2/CppunitTest_chart2_export2.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_export_test,2)) + +# vim: set noet sw=4 ts=4: diff --git a/chart2/Module_chart2.mk b/chart2/Module_chart2.mk index 37acfdc3730f..9bcdd7b363e1 100644 --- a/chart2/Module_chart2.mk +++ b/chart2/Module_chart2.mk @@ -7,6 +7,8 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # +include $(SRCDIR)/chart2/export_setup.mk + $(eval $(call gb_Module_Module,chart2)) $(eval $(call gb_Module_add_targets,chart2,\ @@ -26,6 +28,7 @@ $(eval $(call gb_Module_add_check_targets,chart2,\ $(eval $(call gb_Module_add_slowcheck_targets,chart2,\ CppunitTest_chart2_export \ + CppunitTest_chart2_export2 \ CppunitTest_chart2_import \ CppunitTest_chart2_trendcalculators \ CppunitTest_chart2_dump \ diff --git a/chart2/export_setup.mk b/chart2/export_setup.mk new file mode 100644 index 000000000000..2d1ab7d638de --- /dev/null +++ b/chart2/export_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 export tests +define chart2_export$(1)_test + +$(eval $(call gb_CppunitTest_CppunitTest,chart2_export$(1))) + +$(eval $(call gb_CppunitTest_use_externals,chart2_export$(1), \ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_CppunitTest_add_exception_objects,chart2_export$(1), \ + chart2/qa/extras/chart2export$(1) \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,chart2_export$(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_export$(1),\ + -I$(SRCDIR)/chart2/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,chart2_export$(1))) + +$(eval $(call gb_CppunitTest_use_ure,chart2_export$(1))) +$(eval $(call gb_CppunitTest_use_vcl,chart2_export$(1))) + +$(eval $(call gb_CppunitTest_use_components,chart2_export$(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_export$(1), \ + modules/swriter \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,chart2_export$(1))) + +$(call gb_CppunitTest_get_target,chart2_export$(1)): $(call gb_Package_get_target,postprocess_images) + +endef + +# vim: set noet sw=4 ts=4: diff --git a/chart2/qa/extras/chart2dump/chart2dump.cxx b/chart2/qa/extras/chart2dump/chart2dump.cxx index 061ed8b19ea7..28768ca68957 100644 --- a/chart2/qa/extras/chart2dump/chart2dump.cxx +++ b/chart2/qa/extras/chart2dump/chart2dump.cxx @@ -85,7 +85,7 @@ } \ } -class Chart2DumpTest : public ChartTest, public XmlTestTools +class Chart2DumpTest : public ChartTest { protected: Chart2DumpTest(bool bDumpMode) diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index dabf7b4ed277..dd8b40182d05 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -9,8 +9,6 @@ #include "charttest.hxx" -#include - #include #include #include @@ -18,15 +16,12 @@ #include #include #include -#include #include #include #include #include #include -#include - #include #include @@ -34,13 +29,14 @@ using uno::Reference; using beans::XPropertySet; -class Chart2ExportTest : public ChartTest, public XmlTestTools +class Chart2ExportTest : public ChartTest { protected: virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override; public: Chart2ExportTest() : ChartTest() {} + void testErrorBarXLSX(); void testErrorBarPropXLSX(); void testTrendline(); @@ -132,64 +128,6 @@ public: void testTdf96161(); void testMultipleAxisXLSX(); void testSecondaryAxisXLSX(); - void testSetSeriesToSecondaryAxisXLSX(); - void testCombinedChartSecondaryAxisXLSX(); - void testCombinedChartSecondaryAxisODS(); - void testCrossBetweenXLSX(); - void testCrossBetweenWithDeletedAxis(); - void testCrossBetweenODS(); - void testAxisTitleRotationXLSX(); - void testAxisTitlePositionDOCX(); - void testAxisCrossBetweenDOCX(); - void testPieChartDataPointExplosionXLSX(); - void testCustomDataLabel(); - void testDataSeriesName(); - void testCustomPositionofDataLabel(); - void testCustomDataLabelMultipleSeries(); - void testLeaderLines(); - void testNumberFormatExportPPTX(); - void testLabelSeparatorExportDOCX(); - void testChartTitlePropertiesColorFillPPTX(); - void testChartTitlePropertiesGradientFillPPTX(); - void testChartTitlePropertiesBitmapFillPPTX(); - void testxAxisLabelsRotation(); - void testMultipleCategoryAxisLablesXLSX(); - void testMultipleCategoryAxisLablesDOCX(); - void testTdf116163(); - void testTdf111824(); - void test3DAreaChartZAxis(); - void testTdf119029(); - void testTdf108022(); - void testTdf121744(); - void testTdf121189(); - void testTdf122031(); - void testTdf115012(); - void testTdf134118(); - void testTdf123206_customLabelText(); - void testCustomLabelText(); - void testDeletedLegendEntries(); - void testTdf60316(); - void testTdf130225(); - void testTdf59857(); - void testTdf126076(); - void testTdf75330(); - void testTdf127792(); - void testTdf131979(); - void testTdf132076(); - void testTdf125812(); - void testTdf133190(); - void testTdf133191(); - void testTdf132594(); - void testTdf134255(); - void testTdf134977(); - void testTdf123647(); - void testTdf136267(); - void testDataLabelPlacementPieChart(); - void testTdf137917(); - void testTdf138204(); - void testTdf138181(); - void testCustomShapeText(); - void testuserShapesXLSX(); CPPUNIT_TEST_SUITE(Chart2ExportTest); CPPUNIT_TEST(testErrorBarXLSX); @@ -283,125 +221,10 @@ public: CPPUNIT_TEST(testTdf96161); CPPUNIT_TEST(testMultipleAxisXLSX); CPPUNIT_TEST(testSecondaryAxisXLSX); - CPPUNIT_TEST(testSetSeriesToSecondaryAxisXLSX); - CPPUNIT_TEST(testCombinedChartSecondaryAxisXLSX); - CPPUNIT_TEST(testCombinedChartSecondaryAxisODS); - CPPUNIT_TEST(testCrossBetweenXLSX); - CPPUNIT_TEST(testCrossBetweenWithDeletedAxis); - CPPUNIT_TEST(testCrossBetweenODS); - CPPUNIT_TEST(testAxisTitleRotationXLSX); - CPPUNIT_TEST(testAxisTitlePositionDOCX); - CPPUNIT_TEST(testAxisCrossBetweenDOCX); - CPPUNIT_TEST(testPieChartDataPointExplosionXLSX); - CPPUNIT_TEST(testCustomDataLabel); - CPPUNIT_TEST(testDataSeriesName); - CPPUNIT_TEST(testCustomPositionofDataLabel); - CPPUNIT_TEST(testCustomDataLabelMultipleSeries); - CPPUNIT_TEST(testLeaderLines); - CPPUNIT_TEST(testNumberFormatExportPPTX); - CPPUNIT_TEST(testLabelSeparatorExportDOCX); - CPPUNIT_TEST(testChartTitlePropertiesColorFillPPTX); - CPPUNIT_TEST(testChartTitlePropertiesGradientFillPPTX); - CPPUNIT_TEST(testChartTitlePropertiesBitmapFillPPTX); - CPPUNIT_TEST(testxAxisLabelsRotation); - CPPUNIT_TEST(testMultipleCategoryAxisLablesXLSX); - CPPUNIT_TEST(testMultipleCategoryAxisLablesDOCX); - CPPUNIT_TEST(testTdf116163); - CPPUNIT_TEST(testTdf111824); - CPPUNIT_TEST(test3DAreaChartZAxis); - CPPUNIT_TEST(testTdf119029); - CPPUNIT_TEST(testTdf108022); - CPPUNIT_TEST(testTdf121744); - CPPUNIT_TEST(testTdf121189); - CPPUNIT_TEST(testTdf122031); - CPPUNIT_TEST(testTdf115012); - CPPUNIT_TEST(testTdf134118); - CPPUNIT_TEST(testTdf123206_customLabelText); - CPPUNIT_TEST(testCustomLabelText); - CPPUNIT_TEST(testDeletedLegendEntries); - CPPUNIT_TEST(testTdf60316); - CPPUNIT_TEST(testTdf130225); - CPPUNIT_TEST(testTdf59857); - CPPUNIT_TEST(testTdf126076); - CPPUNIT_TEST(testTdf75330); - CPPUNIT_TEST(testTdf127792); - CPPUNIT_TEST(testTdf131979); - CPPUNIT_TEST(testTdf132076); - CPPUNIT_TEST(testTdf125812); - CPPUNIT_TEST(testTdf133190); - CPPUNIT_TEST(testTdf133191); - CPPUNIT_TEST(testTdf132594); - CPPUNIT_TEST(testTdf134255); - CPPUNIT_TEST(testTdf134977); - CPPUNIT_TEST(testTdf123647); - CPPUNIT_TEST(testTdf136267); - CPPUNIT_TEST(testDataLabelPlacementPieChart); - CPPUNIT_TEST(testTdf137917); - CPPUNIT_TEST(testTdf138204); - CPPUNIT_TEST(testTdf138181); - CPPUNIT_TEST(testCustomShapeText); - CPPUNIT_TEST(testuserShapesXLSX); CPPUNIT_TEST_SUITE_END(); - -protected: - /** - * Given that some problem doesn't affect the result in the importer, we - * test the resulting file directly, by opening the zip file, parsing an - * xml stream, and asserting an XPath expression. This method returns the - * xml stream, so that you can do the asserting. - */ - xmlDocUniquePtr parseExport(const OUString& rDir, const OUString& rFilterFormat); - }; -namespace { - -struct CheckForChartName -{ -private: - OUString aDir; - -public: - explicit CheckForChartName( const OUString& rDir ): - aDir(rDir) {} - - bool operator()(const OUString& rName) - { - if(!rName.startsWith(aDir)) - return false; - - if(!rName.endsWith(".xml")) - return false; - - return true; - } -}; - -OUString findChartFile(const OUString& rDir, uno::Reference< container::XNameAccess > const & xNames ) -{ - uno::Sequence aNames = xNames->getElementNames(); - OUString* pElement = std::find_if(aNames.begin(), aNames.end(), CheckForChartName(rDir)); - - CPPUNIT_ASSERT(pElement != aNames.end()); - return *pElement; -} - -} - -xmlDocUniquePtr Chart2ExportTest::parseExport(const OUString& rDir, const OUString& rFilterFormat) -{ - std::shared_ptr pTempFile = save(rFilterFormat); - - // Read the XML stream we're interested in. - uno::Reference xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), pTempFile->GetURL()); - uno::Reference xInputStream(xNameAccess->getByName(findChartFile(rDir, xNameAccess)), uno::UNO_QUERY); - CPPUNIT_ASSERT(xInputStream.is()); - std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); - - return parseXmlStream(pStream.get()); -} - void Chart2ExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) { XmlTestTools::registerOOXMLNamespaces(pXmlXPathCtx); @@ -2102,1056 +1925,6 @@ void Chart2ExportTest::testSecondaryAxisXLSX() assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart[2]/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v", "a"); } -void Chart2ExportTest::testSetSeriesToSecondaryAxisXLSX() -{ - load(u"/chart2/qa/extras/data/xlsx/", "add_series_secondary_axis.xlsx"); - Reference< chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); - // Second series - Reference xSeries = getDataSeriesFromDoc(xChartDoc, 1); - CPPUNIT_ASSERT(xSeries.is()); - - Reference xPropSet(xSeries, uno::UNO_QUERY_THROW); - sal_Int32 AxisIndex = 1; - // Attach the second series to the secondary axis. (The third series is already attached.) - xPropSet->setPropertyValue("AttachedAxisIndex", uno::Any(AxisIndex)); - - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - // Check there are only two tag in the XML, one for the primary and one for the secondary axis. - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart", 2); -} - -void Chart2ExportTest::testCombinedChartSecondaryAxisXLSX() -{ - // Original file was created with MS Office - load(u"/chart2/qa/extras/data/xlsx/", "combined_chart_secondary_axis.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - // Collect barchart axID on secondary Axis - OUString XValueIdOfBarchart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[1]", "val"); - OUString YValueIdOfBarchart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[2]", "val"); - // Collect linechart axID on primary Axis - OUString XValueIdOfLinechart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[1]", "val"); - OUString YValueIdOfLinechart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[2]", "val"); - // Check which c:catAx and c:valAx contain the AxisId of charttypes - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[1]/c:axId", "val", XValueIdOfLinechart); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:axId", "val", YValueIdOfLinechart); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[2]/c:axId", "val", XValueIdOfBarchart); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:axId", "val", YValueIdOfBarchart); -} - -void Chart2ExportTest::testCombinedChartSecondaryAxisODS() -{ - // Original file was created with LibreOffice - load(u"/chart2/qa/extras/data/ods/", "combined_chart_secondary_axis.ods"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - // Collect barchart axID on secondary Axis - OUString XValueIdOfBarchart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[1]", "val"); - OUString YValueIdOfBarchart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[2]", "val"); - // Collect linechart axID on primary Axis - OUString XValueIdOfLinechart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[1]", "val"); - OUString YValueIdOfLinechart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[2]", "val"); - // Check which c:catAx and c:valAx contain the AxisId of charttypes - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[1]/c:axId", "val", XValueIdOfLinechart); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:axId", "val", YValueIdOfLinechart); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[2]/c:axId", "val", XValueIdOfBarchart); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:axId", "val", YValueIdOfBarchart); - // do not need CT_crosses tag if the actual axis is deleted, so we need to make sure it is not saved - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[2]/c:crosses", 0); -} - -void Chart2ExportTest::testCrossBetweenXLSX() -{ - // Original files were created with MS Office - { - load(u"/chart2/qa/extras/data/xlsx/", "tdf127777.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between"); - } - { - load(u"/chart2/qa/extras/data/xlsx/", "tdf132076.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between"); - } -} - -void Chart2ExportTest::testCrossBetweenWithDeletedAxis() -{ - // Original file was created with MS Office (the category axis is deleted in the file) - load(u"/chart2/qa/extras/data/xlsx/", "tdf128633.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between"); -} - -void Chart2ExportTest::testCrossBetweenODS() -{ - // Original file was created with LibreOffice - load(u"/chart2/qa/extras/data/ods/", "test_CrossBetween.ods"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between"); -} - -void Chart2ExportTest::testAxisTitleRotationXLSX() -{ - load(u"/chart2/qa/extras/data/xlsx/", "axis_title_rotation.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:tx/c:rich/a:bodyPr", "rot", "0"); -} - -void Chart2ExportTest::testAxisTitlePositionDOCX() -{ - load(u"/chart2/qa/extras/data/docx/", "testAxisTitlePosition.docx"); - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); - CPPUNIT_ASSERT(pXmlDoc); - - // test X Axis title position - OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:title/c:layout/c:manualLayout/c:x", "val"); - double nX = aXVal.toDouble(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.698208543867708, nX, 1e-3); - OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:title/c:layout/c:manualLayout/c:y", "val"); - double nY = aYVal.toDouble(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.805152435594555, nY, 1e-3); - - // test Y Axis title position - aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:layout/c:manualLayout/c:x", "val"); - nX = aXVal.toDouble(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0253953671500755, nX, 1e-3); - aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:layout/c:manualLayout/c:y", "val"); - nY = aYVal.toDouble(); - // just test the first two decimal digits because it is not perfect in docx yet. - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.384070199122511, nY, 1e-2); -} - -void Chart2ExportTest::testAxisCrossBetweenDOCX() -{ - load(u"/chart2/qa/extras/data/odt/", "axis-position.odt"); - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); - assertXPath(pXmlDoc, "(//c:crossBetween)[1]", "val", "midCat"); -} - -void Chart2ExportTest::testPieChartDataPointExplosionXLSX() -{ - load(u"/chart2/qa/extras/data/xlsx/", "pie_chart_datapoint_explosion.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dPt/c:explosion", "val", "28"); -} - -void Chart2ExportTest::testCustomDataLabel() -{ - load(u"/chart2/qa/extras/data/pptx/", "tdf115107.pptx"); - xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart1", "Impress MS PowerPoint 2007 XML"); - CPPUNIT_ASSERT(pXmlDoc); - // Check the data labels font color for the complete data series - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/a:defRPr/a:solidFill/a:srgbClr", "val", "404040"); - - Reference xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - float nFontSize; - sal_Int64 nFontColor; - sal_Int32 nCharUnderline; - uno::Reference xPropertySet; - uno::Sequence> aFields; - - // 1 - xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); - xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; - CPPUNIT_ASSERT_EQUAL(static_cast(2), aFields.getLength()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[0]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("90.0 = "), aFields[0]->getString()); - aFields[0]->getPropertyValue("CharHeight") >>= nFontSize; - aFields[0]->getPropertyValue("CharColor") >>= nFontColor; - CPPUNIT_ASSERT_EQUAL(static_cast(18), nFontSize); - CPPUNIT_ASSERT_EQUAL(static_cast(0xed7d31), nFontColor); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, aFields[1]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("90"), aFields[1]->getString()); - CPPUNIT_ASSERT_EQUAL(OUString("{0C576297-5A9F-4B4E-A675-B6BA406B7D87}"), aFields[1]->getGuid()); - - // 2 - xPropertySet.set(xDataSeries->getDataPointByIndex(1), uno::UNO_SET_THROW); - xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; - CPPUNIT_ASSERT_EQUAL(static_cast(8), aFields.getLength()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[0]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("Text"), aFields[0]->getString()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString(" : "), aFields[1]->getString()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CATEGORYNAME, aFields[2]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("B"), aFields[2]->getString()); - CPPUNIT_ASSERT_EQUAL(OUString("{0CCAAACD-B393-42CE-8DBD-82F9F9ADC852}"), aFields[2]->getGuid()); - aFields[2]->getPropertyValue("CharHeight") >>= nFontSize; - aFields[2]->getPropertyValue("CharColor") >>= nFontColor; - CPPUNIT_ASSERT_EQUAL(static_cast(16), nFontSize); - CPPUNIT_ASSERT_EQUAL(static_cast(0xed7d31), nFontColor); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_NEWLINE, aFields[3]->getFieldType()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[4]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("Multi"), aFields[4]->getString()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[5]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("line"), aFields[5]->getString()); - aFields[5]->getPropertyValue("CharHeight") >>= nFontSize; - aFields[5]->getPropertyValue("CharColor") >>= nFontColor; - CPPUNIT_ASSERT_EQUAL(static_cast(11.97), nFontSize); - CPPUNIT_ASSERT_EQUAL(static_cast(0xbf9000), nFontColor); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_NEWLINE, aFields[6]->getFieldType()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[7]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("Abc"), aFields[7]->getString()); - aFields[7]->getPropertyValue("CharHeight") >>= nFontSize; - aFields[7]->getPropertyValue("CharColor") >>= nFontColor; - aFields[7]->getPropertyValue("CharUnderline") >>= nCharUnderline; - CPPUNIT_ASSERT_EQUAL(static_cast(12), nFontSize); - CPPUNIT_ASSERT_EQUAL(static_cast(0xa9d18e), nFontColor); - CPPUNIT_ASSERT_EQUAL(static_cast(1), nCharUnderline); - - // 3 - xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW); - xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; - CPPUNIT_ASSERT_EQUAL(static_cast(1), aFields.getLength()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, aFields[0]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("DATA"), aFields[0]->getString()); - CPPUNIT_ASSERT_EQUAL(OUString("{C8F3EB90-8960-4F9A-A3AD-B4FAC4FE4566}"), aFields[0]->getGuid()); - - // 4 - xPropertySet.set(xDataSeries->getDataPointByIndex(3), uno::UNO_SET_THROW); - xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; - CPPUNIT_ASSERT_EQUAL(static_cast(2), aFields.getLength()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CELLREF, aFields[0]->getFieldType()); - //CPPUNIT_ASSERT_EQUAL(OUString("70"), aFields[0]->getString()); TODO: Not implemented yet - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString(" getString()); -} - -/// Test for tdf#94235 -void Chart2ExportTest::testDataSeriesName() -{ - // ODF - { - load(u"/chart2/qa/extras/data/ods/", "ser_labels.ods"); - reload("calc8"); - uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - uno::Reference xPropertySet; - chart2::DataPointLabel aDataPointLabel; - xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); - xPropertySet->getPropertyValue("Label") >>= aDataPointLabel; - CPPUNIT_ASSERT_EQUAL(sal_True, aDataPointLabel.ShowSeriesName); - } - - // OOXML - { - load(u"/chart2/qa/extras/data/xlsx/", "ser_labels.xlsx"); - reload("Calc Office Open XML"); - uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - uno::Reference xPropertySet; - chart2::DataPointLabel aDataPointLabel; - xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); - xPropertySet->getPropertyValue("Label") >>= aDataPointLabel; - CPPUNIT_ASSERT_EQUAL(sal_True, aDataPointLabel.ShowSeriesName); - } -} - -void Chart2ExportTest::testCustomPositionofDataLabel() -{ - load(u"/chart2/qa/extras/data/xlsx/", "testCustomPosDataLabels.xlsx"); - { - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - // test custom position of data label (xlsx) - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:idx", "val", "2"); - OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:layout/c:manualLayout/c:x", "val"); - double nX = aXVal.toDouble(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.11027682973075476, nX, 1e-7); - - OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:layout/c:manualLayout/c:y", "val"); - double nY = aYVal.toDouble(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.0742140311063737, nY, 1e-7); - } - - load(u"/chart2/qa/extras/data/docx/", "testTdf108110.docx"); - { - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); - CPPUNIT_ASSERT(pXmlDoc); - - // test custom position of data label (docx) - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[2]/c:idx", "val", "2"); - OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[2]/c:layout/c:manualLayout/c:x", "val"); - double nX = aXVal.toDouble(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0227256488772236, nX, 1e-7); - - OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[2]/c:layout/c:manualLayout/c:y", "val"); - double nY = aYVal.toDouble(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.172648731408574, nY, 1e-7); - } - - load(u"/chart2/qa/extras/data/ods/", "tdf136024.ods"); - { - reload("calc8"); - // tdf#136024: test custom position of pie chart data label after an ods export - Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - - Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); - - chart2::RelativePosition aCustomLabelPosition; - CPPUNIT_ASSERT(xPropertySet->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition); - CPPUNIT_ASSERT_DOUBLES_EQUAL(aCustomLabelPosition.Primary, -0.0961935120945059, 1e-5); - CPPUNIT_ASSERT_DOUBLES_EQUAL(aCustomLabelPosition.Secondary, 0.209578842093566, 1e-5); - } -} - -void Chart2ExportTest::testCustomDataLabelMultipleSeries() -{ - load(u"/chart2/qa/extras/data/pptx/", "tdf115107-2.pptx"); - xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart2", "Impress MS PowerPoint 2007 XML"); - CPPUNIT_ASSERT(pXmlDoc); - - Reference xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - float nFontSize; - sal_Int64 nFontColor; - uno::Reference xPropertySet; - uno::Sequence> aFields; - - // First series - xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); - xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; - CPPUNIT_ASSERT_EQUAL(static_cast(3), aFields.getLength()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, aFields[0]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("4.3"), aFields[0]->getString()); - aFields[0]->getPropertyValue("CharHeight") >>= nFontSize; - aFields[0]->getPropertyValue("CharColor") >>= nFontColor; - CPPUNIT_ASSERT_EQUAL(static_cast(18), nFontSize); - CPPUNIT_ASSERT_EQUAL(static_cast(0xc00000), nFontColor); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString(" "), aFields[1]->getString()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, aFields[2]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("Bars"), aFields[2]->getString()); - - // Second series - xDataSeries = getDataSeriesFromDoc(xChartDoc, 0, 1); - CPPUNIT_ASSERT(xDataSeries.is()); - - xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); - xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; - CPPUNIT_ASSERT_EQUAL(static_cast(3), aFields.getLength()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, aFields[0]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("2"), aFields[0]->getString()); - aFields[0]->getPropertyValue("CharHeight") >>= nFontSize; - aFields[0]->getPropertyValue("CharColor") >>= nFontColor; - CPPUNIT_ASSERT_EQUAL(static_cast(18), nFontSize); - CPPUNIT_ASSERT_EQUAL(static_cast(0xffd966), nFontColor); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, aFields[1]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString(" "), aFields[1]->getString()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, aFields[2]->getFieldType()); - CPPUNIT_ASSERT_EQUAL(OUString("Line"), aFields[2]->getString()); - -} - -void Chart2ExportTest::testLeaderLines() -{ - load(u"/chart2/qa/extras/data/xlsx/", "testTdf90749.xlsx"); - { - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:dLbls/c:extLst/c:ext/c15:showLeaderLines", "val", "1"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:dLbls/c:extLst/c:ext/c15:showLeaderLines", "val", "0"); - } - load(u"/chart2/qa/extras/data/docx/", "MSO_Custom_Leader_Line.docx"); - { - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1", "Office Open XML Text"); - CPPUNIT_ASSERT(pXmlDoc); - // tdf#134571: Check the leader line is switch off. - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:extLst/c:ext/c15:showLeaderLines", "val", "0"); - } -} - -void Chart2ExportTest::testNumberFormatExportPPTX() -{ - load(u"/chart2/qa/extras/data/pptx/", "tdf115859.pptx"); - xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:numFmt", "formatCode", "#,##0.00,\\K"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:numFmt", "sourceLinked", "0"); -} - -void Chart2ExportTest::testLabelSeparatorExportDOCX() -{ - load(u"/chart2/qa/extras/data/docx/", "testLabelSeparator.docx"); - - Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text"); - CPPUNIT_ASSERT(pXmlDoc); - - // The text separator should be a new line - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:separator", "\n"); - // The text separator should be a comma - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[2]/c:dLbls/c:separator", ", "); - // The text separator should be a semicolon - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[3]/c:dLbls/c:separator", "; "); -} - -void Chart2ExportTest::testChartTitlePropertiesColorFillPPTX() -{ - load(u"/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesColorFill.pptx"); - xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", "ff0000"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); -} - -void Chart2ExportTest::testChartTitlePropertiesGradientFillPPTX() -{ - load(u"/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesGradientFill.pptx"); - xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", "f6f8fc"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", "c7d5ed"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); -} - -void Chart2ExportTest::testChartTitlePropertiesBitmapFillPPTX() -{ - load(u"/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesBitmapFill.pptx"); - xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip", "embed", "rId1"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); -} - -void Chart2ExportTest::testxAxisLabelsRotation() -{ - load (u"/chart2/qa/extras/data/xlsx/", "xAxisLabelsRotation.xlsx"); - xmlDocUniquePtr pXmlDoc1 = parseExport("xl/charts/chart","Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc1); - - // Chart1 xAxis labels should be 45 degree - assertXPath(pXmlDoc1, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:bodyPr", "rot", "2700000"); -} - -void Chart2ExportTest::testMultipleCategoryAxisLablesXLSX() -{ - load(u"/chart2/qa/extras/data/ods/", "multilevelcat.ods"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - // check category axis labels number of first level - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:ptCount", "val", "6"); - // check category axis labels text of first level - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[1]/c:pt[1]/c:v", "Categoria 1"); - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[1]/c:pt[6]/c:v", "Categoria 6"); - // check category axis labels text of second level - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[2]/c:pt[1]/c:v", "2011"); - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[2]/c:pt[3]/c:v", "2013"); - // check the 'noMultiLvlLbl' tag - ChartExport.cxx:2950 FIXME: seems not support, so check the default noMultiLvlLbl value. - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:noMultiLvlLbl", "val", "0"); -} - -void Chart2ExportTest::testMultipleCategoryAxisLablesDOCX() -{ - load(u"/chart2/qa/extras/data/odt/", "multilevelcat.odt"); - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); - CPPUNIT_ASSERT(pXmlDoc); - // check category axis labels number of first level - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:ptCount", "val", "4"); - // check category axis labels text of first level - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[1]/c:pt[1]/c:v", "Categoria 1"); - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[1]/c:pt[4]/c:v", "Categoria 4"); - // check category axis labels text of second level - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[2]/c:pt[1]/c:v", "2011"); - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[2]/c:pt[2]/c:v", "2012"); - // check the 'noMultiLvlLbl' tag - ChartExport.cxx:2950 FIXME: seems not support, so check the default noMultiLvlLbl value. - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:noMultiLvlLbl", "val", "0"); -} - -void Chart2ExportTest::testTdf116163() -{ - load(u"/chart2/qa/extras/data/pptx/", "tdf116163.pptx"); - xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:bodyPr", "rot", "-5400000"); -} - -void Chart2ExportTest::testTdf111824() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf111824.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - // Collect 3D barchart Z axID - OUString zAxisIdOf3DBarchart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:axId[3]", "val"); - // 3D barchart Z axis properties should be in a serAx OOXML tag instead of catAx - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:serAx/c:axId", "val", zAxisIdOf3DBarchart); -} - -void Chart2ExportTest::test3DAreaChartZAxis() -{ - load(u"/chart2/qa/extras/data/xlsx/", "test3DAreaChartZAxis.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - // Collect 3D area chart Z axID - OUString zAxisIdOf3DAreachart = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:area3DChart/c:axId[3]", "val"); - // 3D area chart z-axis properties should be in a serAx OOXML element instead of catAx - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:serAx/c:axId", "val", zAxisIdOf3DAreachart); -} - -void Chart2ExportTest::testTdf119029() -{ - load(u"/chart2/qa/extras/data/odp/", "tdf119029.odp"); - // Only use "chart", without number, because the number depends on the previous tests - xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, - "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:txPr/a:bodyPr", "rot", - "-5400000"); -} - -void Chart2ExportTest::testTdf108022() -{ - load(u"/chart2/qa/extras/data/odt/", "tdf108022.odt"); - reload("Office Open XML Text"); - - // assert we really have two charts - Reference xChartDoc1(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc1.is()); - Reference xChartDoc2(getChartDocFromWriter(1), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc2.is()); -} - -void Chart2ExportTest::testTdf121744() -{ - load(u"/chart2/qa/extras/data/docx/", "tdf121744.docx"); - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text"); - CPPUNIT_ASSERT(pXmlDoc); - - OUString XValueId = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[1]", "val"); - OUString YValueId = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[2]", "val"); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[1]", "val", XValueId ); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[2]", "val", YValueId ); -} - -void Chart2ExportTest::testTdf121189() -{ - load(u"/chart2/qa/extras/data/odp/", "tdf121189.odp"); - reload("Impress Office Open XML"); - - uno::Reference xDoc(mxComponent, uno::UNO_QUERY_THROW); - uno::Reference xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage->getCount()); - uno::Reference xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.OLE2Shape"), xShape->getShapeType()); -} - -void Chart2ExportTest::testTdf122031() -{ - //Checks pie chart data label format. - - load(u"/chart2/qa/extras/data/xlsx/", "tdf122031.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:numFmt", "formatCode", "0.000%"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[1]/c:numFmt", "formatCode", "0.000%"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[2]/c:numFmt", "formatCode", "0.000%"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[3]/c:numFmt", "formatCode", "0.000%"); -} - -void Chart2ExportTest::testTdf115012() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf115012.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - // workaround: use-zero instead of leave-gap to show the original line chart - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", "zero"); -} - -void Chart2ExportTest::testTdf134118() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf134118.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - // workaround: use leave-gap instead of zero to show the original line chart - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", "gap"); -} - -void Chart2ExportTest::testTdf123206_customLabelText() -{ - load(u"/chart2/qa/extras/data/docx/", "tdf123206.docx"); - - Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/c:rich/a:p/a:r/a:t", "kiscica"); -} - -void Chart2ExportTest::testCustomLabelText() -{ - load(u"/chart2/qa/extras/data/docx/", "testCustomlabeltext.docx"); - - Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[1]/c:idx", "val", "2"); - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[1]/c:tx/c:rich/a:p/a:r[1]/a:t", "3.5"); - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[1]/c:tx/c:rich/a:p/a:r[3]/a:t", "CustomLabel 1"); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[2]/c:idx", "val", "3"); - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/c:rich/a:p/a:r[1]/a:t", "4.5"); - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/c:rich/a:p/a:r[3]/a:t", "CustomLabel 2"); -} - -void Chart2ExportTest::testDeletedLegendEntries() -{ - load(u"/chart2/qa/extras/data/xlsx/", "deleted_legend_entry.xlsx"); - { - reload("Calc Office Open XML"); - Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 1)); - CPPUNIT_ASSERT(xDataSeries.is()); - Reference xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); - bool bShowLegendEntry = true; - CPPUNIT_ASSERT(xPropertySet->getPropertyValue("ShowLegendEntry") >>= bShowLegendEntry); - CPPUNIT_ASSERT(!bShowLegendEntry); - } - - load(u"/chart2/qa/extras/data/xlsx/", "deleted_legend_entry2.xlsx"); - { - reload("Calc Office Open XML"); - Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - Reference xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); - bool bShowLegendEntry = true; - CPPUNIT_ASSERT(xPropertySet->getPropertyValue("ShowLegendEntry") >>= bShowLegendEntry); - CPPUNIT_ASSERT(!bShowLegendEntry); - - Reference xChartDoc2 = getChartDocFromSheet(1, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xDataSeries2(getDataSeriesFromDoc(xChartDoc2, 0)); - CPPUNIT_ASSERT(xDataSeries2.is()); - Reference xPropertySet2(xDataSeries2, uno::UNO_QUERY_THROW); - Sequence deletedLegendEntriesSeq; - CPPUNIT_ASSERT(xPropertySet2->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), deletedLegendEntriesSeq[0]); - } -} - -void Chart2ExportTest::testTdf60316() -{ - load(u"/chart2/qa/extras/data/pptx/", "tdf60316.pptx"); - xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); - CPPUNIT_ASSERT(pXmlDoc); - - // Without the fix in place, the shape would have had a solidFill background - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:noFill", 1); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:solidFill", 0); -} - -void Chart2ExportTest::testTdf130225() -{ - load(u"/chart2/qa/extras/data/docx/", "piechart_deleted_legend_entry.docx"); - reload("Office Open XML Text"); - Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - Reference xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); - Sequence deletedLegendEntriesSeq; - CPPUNIT_ASSERT(xPropertySet->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), deletedLegendEntriesSeq[0]); -} - -void Chart2ExportTest::testTdf59857() -{ - load(u"/chart2/qa/extras/data/ods/", "tdf59857.ods"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:floor/c:spPr/a:ln/a:noFill", 1); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:floor/c:spPr/a:solidFill/a:srgbClr", "val", "cccccc"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:backWall/c:spPr/a:ln/a:noFill", 0); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:backWall/c:spPr/a:ln/a:solidFill/a:srgbClr", "val", "b3b3b3"); -} - -void Chart2ExportTest::testTdf126076() -{ - load(u"/chart2/qa/extras/data/xlsx/", "auto_marker_excel10.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - // This was 12: all series exported with square markers - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:marker/c:symbol[@val='square']", 0); - // instead of skipping markers - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:marker", 0); -} - -void Chart2ExportTest::testTdf75330() -{ - load(u"/chart2/qa/extras/data/ods/", "legend_overlay.ods"); - reload("calc8"); - { - uno::Reference xChart2Doc = getChartDocFromSheet(0, mxComponent); - uno::Reference xChartDoc(xChart2Doc, uno::UNO_QUERY); - uno::Reference xLegend = xChartDoc->getLegend(); - Reference xPropertySet(xLegend, uno::UNO_QUERY_THROW); - bool bOverlay = false; - CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Overlay") >>= bOverlay); - CPPUNIT_ASSERT(bOverlay); - } - reload("Calc Office Open XML"); - { - uno::Reference xChart2Doc = getChartDocFromSheet(0, mxComponent); - uno::Reference xChartDoc(xChart2Doc, uno::UNO_QUERY); - uno::Reference xLegend = xChartDoc->getLegend(); - Reference xPropertySet(xLegend, uno::UNO_QUERY_THROW); - bool bOverlay = false; - CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Overlay") >>= bOverlay); - CPPUNIT_ASSERT(bOverlay); - } -} - -void Chart2ExportTest::testTdf127792() -{ - load(u"/chart2/qa/extras/data/docx/", "MSO_axis_position.docx"); - { - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1", "Office Open XML Text"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "between"); - } - { - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart2", "Office Open XML Text"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", "midCat"); - } -} - -void Chart2ExportTest::testTdf131979() -{ - load(u"/chart2/qa/extras/data/ods/", "tdf131115.ods"); - { - reload("calc8"); - Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - Reference xPropertySet; - xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW); - bool blinknumberformattosource = true; - CPPUNIT_ASSERT(xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= blinknumberformattosource); - CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !blinknumberformattosource); - } - - load(u"/chart2/qa/extras/data/ods/", "tdf131979.ods"); - { - reload("calc8"); - Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); - CPPUNIT_ASSERT(xDataSeries.is()); - Reference xPropertySet; - xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW); - bool blinknumberformattosource = true; - CPPUNIT_ASSERT(xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= blinknumberformattosource); - CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", blinknumberformattosource); - } -} - -void Chart2ExportTest::testTdf132076() -{ - { - load(u"/chart2/qa/extras/data/ods/", "tdf132076.ods"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:numFmt", "formatCode", "dd"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:numFmt", "sourceLinked", "0"); - } - { - load(u"/chart2/qa/extras/data/xlsx/", "tdf132076.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:numFmt", "formatCode", "dd"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:numFmt", "sourceLinked", "0"); - } -} - -void Chart2ExportTest::testTdf125812() -{ - load(u"/chart2/qa/extras/data/odp/", "ellipticalGradientFill.odp"); - xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path", "path", "circle"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", "l", "50000"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", "t", "49000"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", "r", "50000"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", "b", "51000"); -} - -void Chart2ExportTest::testTdf133190() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf133190_tdf133191.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - // Test word wrap of data point label - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[1]/c:txPr/a:bodyPr", "wrap", "none"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[2]/c:txPr/a:bodyPr", "wrap", "square"); -} - -void Chart2ExportTest::testTdf133191() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf133190_tdf133191.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - // Test rotation of data point label - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[3]/c:txPr/a:bodyPr", "rot", "-4500000"); -} - -void Chart2ExportTest::testTdf132594() -{ - load(u"/chart2/qa/extras/data/xlsx/", "chart_pie2007.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:cat", 1); -} - -void Chart2ExportTest::testTdf134255() -{ - load(u"/chart2/qa/extras/data/docx/", "tdf134255.docx"); - Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xChartDoc.is()); - - // import test - Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); - CPPUNIT_ASSERT(xDataSeries.is()); - Reference< beans::XPropertySet > xPropSet(xDataSeries, UNO_QUERY_THROW); - bool bWrap = false; - CPPUNIT_ASSERT((xPropSet->getPropertyValue("TextWordWrap") >>= bWrap)); - CPPUNIT_ASSERT(bWrap); - - // export test - xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:txPr/a:bodyPr", "wrap", "square"); -} - -void Chart2ExportTest::testTdf134977() -{ - load(u"/chart2/qa/extras/data/xlsx/", "custom_data_label.xlsx"); - - //import test - uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - Reference< chart2::XDataSeries > xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); - CPPUNIT_ASSERT(xDataSeries.is()); - uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); - uno::Sequence> aFields; - float nFontSize; - xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; - aFields[0]->getPropertyValue("CharHeight") >>= nFontSize; - CPPUNIT_ASSERT_EQUAL(static_cast(9), nFontSize); - - //export test - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl/c:tx/c:rich/a:p/a:r/a:rPr", "sz", "900"); -} - -void Chart2ExportTest::testTdf123647() -{ - load(u"/chart2/qa/extras/data/xlsx/", "empty_chart.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart","Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart", 1); -} - -void Chart2ExportTest::testTdf136267() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf136267.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:cat/c:strRef/c:strCache/c:pt/c:v", "John"); -} - -void Chart2ExportTest::testDataLabelPlacementPieChart() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf134978.xlsx"); - reload("calc8"); - uno::Reference xChartDoc(getChartCompFromSheet(0, mxComponent), - UNO_QUERY_THROW); - // test the placement of the manually positioned label - Reference - xDataPointPropSet(xChartDoc->getDiagram()->getDataPointProperties(2, 0), - uno::UNO_SET_THROW); - uno::Any aAny = xDataPointPropSet->getPropertyValue("LabelPlacement"); - CPPUNIT_ASSERT(aAny.hasValue()); - sal_Int32 nLabelPlacement = 0; - CPPUNIT_ASSERT(aAny >>= nLabelPlacement); - CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::OUTSIDE, nLabelPlacement); -} - -void Chart2ExportTest::testTdf137917() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf137917.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:baseTimeUnit", "val", "days"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:majorUnit", "val", "1"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:majorTimeUnit", "val", "months"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:minorUnit", "val", "7"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:minorTimeUnit", "val", "days"); -} - -void Chart2ExportTest::testTdf138204() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf138204.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - - // Check the first data label field type - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLbl/c:tx/c:rich/a:p/a:fld", "type", "CELLRANGE"); - - Reference< chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - - uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 1)); - CPPUNIT_ASSERT(xDataSeries.is()); - - uno::Reference xPropertySet; - uno::Sequence> aFields; - xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); - xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; - CPPUNIT_ASSERT_EQUAL(static_cast(1), aFields.getLength()); - - CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CELLRANGE, aFields[0]->getFieldType()); - //CPPUNIT_ASSERT_EQUAL(OUString("67.5%"), aFields[0]->getString()); TODO: Not implemented yet -} - -void Chart2ExportTest::testTdf138181() -{ - load(u"/chart2/qa/extras/data/xlsx/", "piechart_deleted_legendentry.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 xLegendEntry1, xLegendEntry2, xLegendEntry3; - - // first legend entry is visible - xLegendEntry1 - = getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=0:Point=0:LegendEntry=0"); - CPPUNIT_ASSERT(xLegendEntry1.is()); - - // second legend entry is not visible - xLegendEntry2 - = getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=0:Point=1:LegendEntry=0"); - CPPUNIT_ASSERT(!xLegendEntry2.is()); - - // third legend entry is visible - xLegendEntry3 - = getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=0:Point=2:LegendEntry=0"); - CPPUNIT_ASSERT(xLegendEntry3.is()); -} - -void Chart2ExportTest::testCustomShapeText() -{ - load(u"/chart2/qa/extras/data/ods/", "tdf72776.ods"); - reload("calc8"); - Reference xChartDoc(getChartDocFromSheet(0, mxComponent), - UNO_QUERY_THROW); - // test that the text of custom shape exists inside the chart - 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()); - - Reference< text::XText > xRange(xCustomShape, uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT(!xRange->getString().isEmpty()); -} - -void Chart2ExportTest::testuserShapesXLSX() -{ - load(u"/chart2/qa/extras/data/xlsx/", "tdf128621.xlsx"); - reload("Calc Office Open XML"); - - Reference< chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); - CPPUNIT_ASSERT(xChartDoc.is()); - - // test that the custom shape exists - 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()); - // test type of shape - CPPUNIT_ASSERT(xCustomShape->getShapeType().endsWith("CustomShape")); - // test custom shape position - awt::Point aPosition = xCustomShape->getPosition(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1356, aPosition.X, 300); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9107, aPosition.Y, 300); - // test custom shape size - awt::Size aSize = xCustomShape->getSize(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9520, aSize.Width, 300); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1805, aSize.Height, 300); - // test custom shape text - Reference< text::XText > xRange(xCustomShape, uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT(!xRange->getString().isEmpty()); -} - CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/chart2export2.cxx b/chart2/qa/extras/chart2export2.cxx new file mode 100644 index 000000000000..e05d984f75cf --- /dev/null +++ b/chart2/qa/extras/chart2export2.cxx @@ -0,0 +1,1427 @@ +/* -*- 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 + +using uno::Reference; +using beans::XPropertySet; + +class Chart2ExportTest2 : public ChartTest +{ +protected: + virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override; + +public: + Chart2ExportTest2() + : ChartTest() + { + } + void testSetSeriesToSecondaryAxisXLSX(); + void testCombinedChartSecondaryAxisXLSX(); + void testCombinedChartSecondaryAxisODS(); + void testCrossBetweenXLSX(); + void testCrossBetweenWithDeletedAxis(); + void testCrossBetweenODS(); + void testAxisTitleRotationXLSX(); + void testAxisTitlePositionDOCX(); + void testAxisCrossBetweenDOCX(); + void testPieChartDataPointExplosionXLSX(); + void testCustomDataLabel(); + void testDataSeriesName(); + void testCustomPositionofDataLabel(); + void testCustomDataLabelMultipleSeries(); + void testLeaderLines(); + void testNumberFormatExportPPTX(); + void testLabelSeparatorExportDOCX(); + void testChartTitlePropertiesColorFillPPTX(); + void testChartTitlePropertiesGradientFillPPTX(); + void testChartTitlePropertiesBitmapFillPPTX(); + void testxAxisLabelsRotation(); + void testMultipleCategoryAxisLablesXLSX(); + void testMultipleCategoryAxisLablesDOCX(); + void testTdf116163(); + void testTdf111824(); + void test3DAreaChartZAxis(); + void testTdf119029(); + void testTdf108022(); + void testTdf121744(); + void testTdf121189(); + void testTdf122031(); + void testTdf115012(); + void testTdf134118(); + void testTdf123206_customLabelText(); + void testCustomLabelText(); + void testDeletedLegendEntries(); + void testTdf60316(); + void testTdf130225(); + void testTdf59857(); + void testTdf126076(); + void testTdf75330(); + void testTdf127792(); + void testTdf131979(); + void testTdf132076(); + void testTdf125812(); + void testTdf133190(); + void testTdf133191(); + void testTdf132594(); + void testTdf134255(); + void testTdf134977(); + void testTdf123647(); + void testTdf136267(); + void testDataLabelPlacementPieChart(); + void testTdf137917(); + void testTdf138204(); + void testTdf138181(); + void testCustomShapeText(); + void testuserShapesXLSX(); + + CPPUNIT_TEST_SUITE(Chart2ExportTest2); + CPPUNIT_TEST(testSetSeriesToSecondaryAxisXLSX); + CPPUNIT_TEST(testCombinedChartSecondaryAxisXLSX); + CPPUNIT_TEST(testCombinedChartSecondaryAxisODS); + CPPUNIT_TEST(testCrossBetweenXLSX); + CPPUNIT_TEST(testCrossBetweenWithDeletedAxis); + CPPUNIT_TEST(testCrossBetweenODS); + CPPUNIT_TEST(testAxisTitleRotationXLSX); + CPPUNIT_TEST(testAxisTitlePositionDOCX); + CPPUNIT_TEST(testAxisCrossBetweenDOCX); + CPPUNIT_TEST(testPieChartDataPointExplosionXLSX); + CPPUNIT_TEST(testCustomDataLabel); + CPPUNIT_TEST(testDataSeriesName); + CPPUNIT_TEST(testCustomPositionofDataLabel); + CPPUNIT_TEST(testCustomDataLabelMultipleSeries); + CPPUNIT_TEST(testLeaderLines); + CPPUNIT_TEST(testNumberFormatExportPPTX); + CPPUNIT_TEST(testLabelSeparatorExportDOCX); + CPPUNIT_TEST(testChartTitlePropertiesColorFillPPTX); + CPPUNIT_TEST(testChartTitlePropertiesGradientFillPPTX); + CPPUNIT_TEST(testChartTitlePropertiesBitmapFillPPTX); + CPPUNIT_TEST(testxAxisLabelsRotation); + CPPUNIT_TEST(testMultipleCategoryAxisLablesXLSX); + CPPUNIT_TEST(testMultipleCategoryAxisLablesDOCX); + CPPUNIT_TEST(testTdf116163); + CPPUNIT_TEST(testTdf111824); + CPPUNIT_TEST(test3DAreaChartZAxis); + CPPUNIT_TEST(testTdf119029); + CPPUNIT_TEST(testTdf108022); + CPPUNIT_TEST(testTdf121744); + CPPUNIT_TEST(testTdf121189); + CPPUNIT_TEST(testTdf122031); + CPPUNIT_TEST(testTdf115012); + CPPUNIT_TEST(testTdf134118); + CPPUNIT_TEST(testTdf123206_customLabelText); + CPPUNIT_TEST(testCustomLabelText); + CPPUNIT_TEST(testDeletedLegendEntries); + CPPUNIT_TEST(testTdf60316); + CPPUNIT_TEST(testTdf130225); + CPPUNIT_TEST(testTdf59857); + CPPUNIT_TEST(testTdf126076); + CPPUNIT_TEST(testTdf75330); + CPPUNIT_TEST(testTdf127792); + CPPUNIT_TEST(testTdf131979); + CPPUNIT_TEST(testTdf132076); + CPPUNIT_TEST(testTdf125812); + CPPUNIT_TEST(testTdf133190); + CPPUNIT_TEST(testTdf133191); + CPPUNIT_TEST(testTdf132594); + CPPUNIT_TEST(testTdf134255); + CPPUNIT_TEST(testTdf134977); + CPPUNIT_TEST(testTdf123647); + CPPUNIT_TEST(testTdf136267); + CPPUNIT_TEST(testDataLabelPlacementPieChart); + CPPUNIT_TEST(testTdf137917); + CPPUNIT_TEST(testTdf138204); + CPPUNIT_TEST(testTdf138181); + CPPUNIT_TEST(testCustomShapeText); + CPPUNIT_TEST(testuserShapesXLSX); + CPPUNIT_TEST_SUITE_END(); +}; + +void Chart2ExportTest2::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) +{ + XmlTestTools::registerOOXMLNamespaces(pXmlXPathCtx); +} + +void Chart2ExportTest2::testSetSeriesToSecondaryAxisXLSX() +{ + load(u"/chart2/qa/extras/data/xlsx/", "add_series_secondary_axis.xlsx"); + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + // Second series + Reference xSeries = getDataSeriesFromDoc(xChartDoc, 1); + CPPUNIT_ASSERT(xSeries.is()); + + Reference xPropSet(xSeries, uno::UNO_QUERY_THROW); + sal_Int32 AxisIndex = 1; + // Attach the second series to the secondary axis. (The third series is already attached.) + xPropSet->setPropertyValue("AttachedAxisIndex", uno::Any(AxisIndex)); + + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + // Check there are only two tag in the XML, one for the primary and one for the secondary axis. + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart", 2); +} + +void Chart2ExportTest2::testCombinedChartSecondaryAxisXLSX() +{ + // Original file was created with MS Office + load(u"/chart2/qa/extras/data/xlsx/", "combined_chart_secondary_axis.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + // Collect barchart axID on secondary Axis + OUString XValueIdOfBarchart + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[1]", "val"); + OUString YValueIdOfBarchart + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[2]", "val"); + // Collect linechart axID on primary Axis + OUString XValueIdOfLinechart + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[1]", "val"); + OUString YValueIdOfLinechart + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[2]", "val"); + // Check which c:catAx and c:valAx contain the AxisId of charttypes + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[1]/c:axId", "val", + XValueIdOfLinechart); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:axId", "val", + YValueIdOfLinechart); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[2]/c:axId", "val", + XValueIdOfBarchart); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:axId", "val", + YValueIdOfBarchart); +} + +void Chart2ExportTest2::testCombinedChartSecondaryAxisODS() +{ + // Original file was created with LibreOffice + load(u"/chart2/qa/extras/data/ods/", "combined_chart_secondary_axis.ods"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + // Collect barchart axID on secondary Axis + OUString XValueIdOfBarchart + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[1]", "val"); + OUString YValueIdOfBarchart + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[2]", "val"); + // Collect linechart axID on primary Axis + OUString XValueIdOfLinechart + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[1]", "val"); + OUString YValueIdOfLinechart + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[2]", "val"); + // Check which c:catAx and c:valAx contain the AxisId of charttypes + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[1]/c:axId", "val", + XValueIdOfLinechart); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[1]/c:axId", "val", + YValueIdOfLinechart); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[2]/c:axId", "val", + XValueIdOfBarchart); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx[2]/c:axId", "val", + YValueIdOfBarchart); + // do not need CT_crosses tag if the actual axis is deleted, so we need to make sure it is not saved + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx[2]/c:crosses", 0); +} + +void Chart2ExportTest2::testCrossBetweenXLSX() +{ + // Original files were created with MS Office + { + load(u"/chart2/qa/extras/data/xlsx/", "tdf127777.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", + "between"); + } + { + load(u"/chart2/qa/extras/data/xlsx/", "tdf132076.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", + "between"); + } +} + +void Chart2ExportTest2::testCrossBetweenWithDeletedAxis() +{ + // Original file was created with MS Office (the category axis is deleted in the file) + load(u"/chart2/qa/extras/data/xlsx/", "tdf128633.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", + "between"); +} + +void Chart2ExportTest2::testCrossBetweenODS() +{ + // Original file was created with LibreOffice + load(u"/chart2/qa/extras/data/ods/", "test_CrossBetween.ods"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", + "between"); +} + +void Chart2ExportTest2::testAxisTitleRotationXLSX() +{ + load(u"/chart2/qa/extras/data/xlsx/", "axis_title_rotation.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:tx/c:rich/a:bodyPr", + "rot", "0"); +} + +void Chart2ExportTest2::testAxisTitlePositionDOCX() +{ + load(u"/chart2/qa/extras/data/docx/", "testAxisTitlePosition.docx"); + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + + // test X Axis title position + OUString aXVal = getXPath( + pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:title/c:layout/c:manualLayout/c:x", + "val"); + double nX = aXVal.toDouble(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.698208543867708, nX, 1e-3); + OUString aYVal = getXPath( + pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:title/c:layout/c:manualLayout/c:y", + "val"); + double nY = aYVal.toDouble(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.805152435594555, nY, 1e-3); + + // test Y Axis title position + aXVal = getXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:layout/c:manualLayout/c:x", + "val"); + nX = aXVal.toDouble(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0253953671500755, nX, 1e-3); + aYVal = getXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:title/c:layout/c:manualLayout/c:y", + "val"); + nY = aYVal.toDouble(); + // just test the first two decimal digits because it is not perfect in docx yet. + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.384070199122511, nY, 1e-2); +} + +void Chart2ExportTest2::testAxisCrossBetweenDOCX() +{ + load(u"/chart2/qa/extras/data/odt/", "axis-position.odt"); + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); + assertXPath(pXmlDoc, "(//c:crossBetween)[1]", "val", "midCat"); +} + +void Chart2ExportTest2::testPieChartDataPointExplosionXLSX() +{ + load(u"/chart2/qa/extras/data/xlsx/", "pie_chart_datapoint_explosion.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dPt/c:explosion", + "val", "28"); +} + +void Chart2ExportTest2::testCustomDataLabel() +{ + load(u"/chart2/qa/extras/data/pptx/", "tdf115107.pptx"); + xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart1", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + // Check the data labels font color for the complete data series + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:txPr/a:p/a:pPr/" + "a:defRPr/a:solidFill/a:srgbClr", + "val", "404040"); + + Reference xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + float nFontSize; + sal_Int64 nFontColor; + sal_Int32 nCharUnderline; + uno::Reference xPropertySet; + uno::Sequence> aFields; + + // 1 + xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); + xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; + CPPUNIT_ASSERT_EQUAL(static_cast(2), aFields.getLength()); + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, + aFields[0]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("90.0 = "), aFields[0]->getString()); + aFields[0]->getPropertyValue("CharHeight") >>= nFontSize; + aFields[0]->getPropertyValue("CharColor") >>= nFontColor; + CPPUNIT_ASSERT_EQUAL(static_cast(18), nFontSize); + CPPUNIT_ASSERT_EQUAL(static_cast(0xed7d31), nFontColor); + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, + aFields[1]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("90"), aFields[1]->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("{0C576297-5A9F-4B4E-A675-B6BA406B7D87}"), aFields[1]->getGuid()); + + // 2 + xPropertySet.set(xDataSeries->getDataPointByIndex(1), uno::UNO_SET_THROW); + xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; + CPPUNIT_ASSERT_EQUAL(static_cast(8), aFields.getLength()); + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, + aFields[0]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("Text"), aFields[0]->getString()); + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, + aFields[1]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString(" : "), aFields[1]->getString()); + + CPPUNIT_ASSERT_EQUAL( + chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CATEGORYNAME, + aFields[2]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("B"), aFields[2]->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("{0CCAAACD-B393-42CE-8DBD-82F9F9ADC852}"), aFields[2]->getGuid()); + aFields[2]->getPropertyValue("CharHeight") >>= nFontSize; + aFields[2]->getPropertyValue("CharColor") >>= nFontColor; + CPPUNIT_ASSERT_EQUAL(static_cast(16), nFontSize); + CPPUNIT_ASSERT_EQUAL(static_cast(0xed7d31), nFontColor); + + CPPUNIT_ASSERT_EQUAL( + chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_NEWLINE, + aFields[3]->getFieldType()); + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, + aFields[4]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("Multi"), aFields[4]->getString()); + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, + aFields[5]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("line"), aFields[5]->getString()); + aFields[5]->getPropertyValue("CharHeight") >>= nFontSize; + aFields[5]->getPropertyValue("CharColor") >>= nFontColor; + CPPUNIT_ASSERT_EQUAL(static_cast(11.97), nFontSize); + CPPUNIT_ASSERT_EQUAL(static_cast(0xbf9000), nFontColor); + + CPPUNIT_ASSERT_EQUAL( + chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_NEWLINE, + aFields[6]->getFieldType()); + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, + aFields[7]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("Abc"), aFields[7]->getString()); + aFields[7]->getPropertyValue("CharHeight") >>= nFontSize; + aFields[7]->getPropertyValue("CharColor") >>= nFontColor; + aFields[7]->getPropertyValue("CharUnderline") >>= nCharUnderline; + CPPUNIT_ASSERT_EQUAL(static_cast(12), nFontSize); + CPPUNIT_ASSERT_EQUAL(static_cast(0xa9d18e), nFontColor); + CPPUNIT_ASSERT_EQUAL(static_cast(1), nCharUnderline); + + // 3 + xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW); + xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; + CPPUNIT_ASSERT_EQUAL(static_cast(1), aFields.getLength()); + + CPPUNIT_ASSERT_EQUAL( + chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, + aFields[0]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("DATA"), aFields[0]->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("{C8F3EB90-8960-4F9A-A3AD-B4FAC4FE4566}"), aFields[0]->getGuid()); + + // 4 + xPropertySet.set(xDataSeries->getDataPointByIndex(3), uno::UNO_SET_THROW); + xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; + CPPUNIT_ASSERT_EQUAL(static_cast(2), aFields.getLength()); + + CPPUNIT_ASSERT_EQUAL( + chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CELLREF, + aFields[0]->getFieldType()); + //CPPUNIT_ASSERT_EQUAL(OUString("70"), aFields[0]->getString()); TODO: Not implemented yet + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, + aFields[1]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString(" getString()); +} + +/// Test for tdf#94235 +void Chart2ExportTest2::testDataSeriesName() +{ + // ODF + { + load(u"/chart2/qa/extras/data/ods/", "ser_labels.ods"); + reload("calc8"); + uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + uno::Reference xPropertySet; + chart2::DataPointLabel aDataPointLabel; + xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); + xPropertySet->getPropertyValue("Label") >>= aDataPointLabel; + CPPUNIT_ASSERT_EQUAL(sal_True, aDataPointLabel.ShowSeriesName); + } + + // OOXML + { + load(u"/chart2/qa/extras/data/xlsx/", "ser_labels.xlsx"); + reload("Calc Office Open XML"); + uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + uno::Reference xPropertySet; + chart2::DataPointLabel aDataPointLabel; + xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); + xPropertySet->getPropertyValue("Label") >>= aDataPointLabel; + CPPUNIT_ASSERT_EQUAL(sal_True, aDataPointLabel.ShowSeriesName); + } +} + +void Chart2ExportTest2::testCustomPositionofDataLabel() +{ + load(u"/chart2/qa/extras/data/xlsx/", "testCustomPosDataLabels.xlsx"); + { + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + // test custom position of data label (xlsx) + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[1]/c:idx", + "val", "2"); + OUString aXVal = getXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/" + "c:dLbl[1]/c:layout/c:manualLayout/c:x", + "val"); + double nX = aXVal.toDouble(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.11027682973075476, nX, 1e-7); + + OUString aYVal = getXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/" + "c:dLbl[1]/c:layout/c:manualLayout/c:y", + "val"); + double nY = aYVal.toDouble(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.0742140311063737, nY, 1e-7); + } + + load(u"/chart2/qa/extras/data/docx/", "testTdf108110.docx"); + { + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + + // test custom position of data label (docx) + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/c:dLbl[2]/c:idx", + "val", "2"); + OUString aXVal = getXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/" + "c:dLbl[2]/c:layout/c:manualLayout/c:x", + "val"); + double nX = aXVal.toDouble(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0227256488772236, nX, 1e-7); + + OUString aYVal = getXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:dLbls/" + "c:dLbl[2]/c:layout/c:manualLayout/c:y", + "val"); + double nY = aYVal.toDouble(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.172648731408574, nY, 1e-7); + } + + load(u"/chart2/qa/extras/data/ods/", "tdf136024.ods"); + { + reload("calc8"); + // tdf#136024: test custom position of pie chart data label after an ods export + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + + Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(0), + uno::UNO_SET_THROW); + + chart2::RelativePosition aCustomLabelPosition; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("CustomLabelPosition") + >>= aCustomLabelPosition); + CPPUNIT_ASSERT_DOUBLES_EQUAL(aCustomLabelPosition.Primary, -0.0961935120945059, 1e-5); + CPPUNIT_ASSERT_DOUBLES_EQUAL(aCustomLabelPosition.Secondary, 0.209578842093566, 1e-5); + } +} + +void Chart2ExportTest2::testCustomDataLabelMultipleSeries() +{ + load(u"/chart2/qa/extras/data/pptx/", "tdf115107-2.pptx"); + xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart2", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + + Reference xChartDoc(getChartDocFromDrawImpress(0, 0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + float nFontSize; + sal_Int64 nFontColor; + uno::Reference xPropertySet; + uno::Sequence> aFields; + + // First series + xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); + xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; + CPPUNIT_ASSERT_EQUAL(static_cast(3), aFields.getLength()); + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, + aFields[0]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("4.3"), aFields[0]->getString()); + aFields[0]->getPropertyValue("CharHeight") >>= nFontSize; + aFields[0]->getPropertyValue("CharColor") >>= nFontColor; + CPPUNIT_ASSERT_EQUAL(static_cast(18), nFontSize); + CPPUNIT_ASSERT_EQUAL(static_cast(0xc00000), nFontColor); + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, + aFields[1]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), aFields[1]->getString()); + + CPPUNIT_ASSERT_EQUAL( + chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, + aFields[2]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("Bars"), aFields[2]->getString()); + + // Second series + xDataSeries = getDataSeriesFromDoc(xChartDoc, 0, 1); + CPPUNIT_ASSERT(xDataSeries.is()); + + xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); + xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; + CPPUNIT_ASSERT_EQUAL(static_cast(3), aFields.getLength()); + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_VALUE, + aFields[0]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("2"), aFields[0]->getString()); + aFields[0]->getPropertyValue("CharHeight") >>= nFontSize; + aFields[0]->getPropertyValue("CharColor") >>= nFontColor; + CPPUNIT_ASSERT_EQUAL(static_cast(18), nFontSize); + CPPUNIT_ASSERT_EQUAL(static_cast(0xffd966), nFontColor); + + CPPUNIT_ASSERT_EQUAL(chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT, + aFields[1]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString(" "), aFields[1]->getString()); + + CPPUNIT_ASSERT_EQUAL( + chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_SERIESNAME, + aFields[2]->getFieldType()); + CPPUNIT_ASSERT_EQUAL(OUString("Line"), aFields[2]->getString()); +} + +void Chart2ExportTest2::testLeaderLines() +{ + load(u"/chart2/qa/extras/data/xlsx/", "testTdf90749.xlsx"); + { + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:dLbls/c:extLst/c:ext/" + "c15:showLeaderLines", + "val", "1"); + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:dLbls/c:extLst/c:ext/" + "c15:showLeaderLines", + "val", "0"); + } + load(u"/chart2/qa/extras/data/docx/", "MSO_Custom_Leader_Line.docx"); + { + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + // tdf#134571: Check the leader line is switch off. + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:extLst/c:ext/" + "c15:showLeaderLines", + "val", "0"); + } +} + +void Chart2ExportTest2::testNumberFormatExportPPTX() +{ + load(u"/chart2/qa/extras/data/pptx/", "tdf115859.pptx"); + xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:numFmt", + "formatCode", "#,##0.00,\\K"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:numFmt", + "sourceLinked", "0"); +} + +void Chart2ExportTest2::testLabelSeparatorExportDOCX() +{ + load(u"/chart2/qa/extras/data/docx/", "testLabelSeparator.docx"); + + Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + + // The text separator should be a new line + assertXPathContent( + pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:separator", "\n"); + // The text separator should be a comma + assertXPathContent( + pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[2]/c:dLbls/c:separator", ", "); + // The text separator should be a semicolon + assertXPathContent( + pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[3]/c:dLbls/c:separator", "; "); +} + +void Chart2ExportTest2::testChartTitlePropertiesColorFillPPTX() +{ + load(u"/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesColorFill.pptx"); + xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:solidFill/a:srgbClr", "val", + "ff0000"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + +void Chart2ExportTest2::testChartTitlePropertiesGradientFillPPTX() +{ + load(u"/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesGradientFill.pptx"); + xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", + "f6f8fc"); + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:title/c:spPr/a:gradFill/a:gsLst/a:gs[2]/a:srgbClr", "val", + "c7d5ed"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + +void Chart2ExportTest2::testChartTitlePropertiesBitmapFillPPTX() +{ + load(u"/chart2/qa/extras/data/pptx/", "testChartTitlePropertiesBitmapFill.pptx"); + xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:blipFill/a:blip", "embed", "rId1"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:spPr/a:ln/a:noFill", 1); +} + +void Chart2ExportTest2::testxAxisLabelsRotation() +{ + load(u"/chart2/qa/extras/data/xlsx/", "xAxisLabelsRotation.xlsx"); + xmlDocUniquePtr pXmlDoc1 = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc1); + + // Chart1 xAxis labels should be 45 degree + assertXPath(pXmlDoc1, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:bodyPr", "rot", + "2700000"); +} + +void Chart2ExportTest2::testMultipleCategoryAxisLablesXLSX() +{ + load(u"/chart2/qa/extras/data/ods/", "multilevelcat.ods"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + // check category axis labels number of first level + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/" + "c:multiLvlStrCache/c:ptCount", + "val", "6"); + // check category axis labels text of first level + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/" + "c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[1]/c:pt[1]/c:v", + "Categoria 1"); + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/" + "c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[1]/c:pt[6]/c:v", + "Categoria 6"); + // check category axis labels text of second level + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/" + "c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[2]/c:pt[1]/c:v", + "2011"); + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/" + "c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[2]/c:pt[3]/c:v", + "2013"); + // check the 'noMultiLvlLbl' tag - ChartExport.cxx:2950 FIXME: seems not support, so check the default noMultiLvlLbl value. + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:noMultiLvlLbl", "val", "0"); +} + +void Chart2ExportTest2::testMultipleCategoryAxisLablesDOCX() +{ + load(u"/chart2/qa/extras/data/odt/", "multilevelcat.odt"); + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + // check category axis labels number of first level + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:multiLvlStrRef/" + "c:multiLvlStrCache/c:ptCount", + "val", "4"); + // check category axis labels text of first level + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/" + "c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[1]/c:pt[1]/c:v", + "Categoria 1"); + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/" + "c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[1]/c:pt[4]/c:v", + "Categoria 4"); + // check category axis labels text of second level + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/" + "c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[2]/c:pt[1]/c:v", + "2011"); + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/" + "c:multiLvlStrRef/c:multiLvlStrCache/c:lvl[2]/c:pt[2]/c:v", + "2012"); + // check the 'noMultiLvlLbl' tag - ChartExport.cxx:2950 FIXME: seems not support, so check the default noMultiLvlLbl value. + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:noMultiLvlLbl", "val", "0"); +} + +void Chart2ExportTest2::testTdf116163() +{ + load(u"/chart2/qa/extras/data/pptx/", "tdf116163.pptx"); + xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:txPr/a:bodyPr", "rot", + "-5400000"); +} + +void Chart2ExportTest2::testTdf111824() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf111824.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + // Collect 3D barchart Z axID + OUString zAxisIdOf3DBarchart + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:bar3DChart/c:axId[3]", "val"); + // 3D barchart Z axis properties should be in a serAx OOXML tag instead of catAx + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:serAx/c:axId", "val", + zAxisIdOf3DBarchart); +} + +void Chart2ExportTest2::test3DAreaChartZAxis() +{ + load(u"/chart2/qa/extras/data/xlsx/", "test3DAreaChartZAxis.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + // Collect 3D area chart Z axID + OUString zAxisIdOf3DAreachart + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:area3DChart/c:axId[3]", "val"); + // 3D area chart z-axis properties should be in a serAx OOXML element instead of catAx + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:serAx/c:axId", "val", + zAxisIdOf3DAreachart); +} + +void Chart2ExportTest2::testTdf119029() +{ + load(u"/chart2/qa/extras/data/odp/", "tdf119029.odp"); + // Only use "chart", without number, because the number depends on the previous tests + xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:txPr/a:bodyPr", "rot", + "-5400000"); +} + +void Chart2ExportTest2::testTdf108022() +{ + load(u"/chart2/qa/extras/data/odt/", "tdf108022.odt"); + reload("Office Open XML Text"); + + // assert we really have two charts + Reference xChartDoc1(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc1.is()); + Reference xChartDoc2(getChartDocFromWriter(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc2.is()); +} + +void Chart2ExportTest2::testTdf121744() +{ + load(u"/chart2/qa/extras/data/docx/", "tdf121744.docx"); + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + + OUString XValueId + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[1]", "val"); + OUString YValueId + = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:axId[2]", "val"); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[1]", "val", XValueId); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:axId[2]", "val", YValueId); +} + +void Chart2ExportTest2::testTdf121189() +{ + load(u"/chart2/qa/extras/data/odp/", "tdf121189.odp"); + reload("Impress Office Open XML"); + + uno::Reference xDoc(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference xPage(xDoc->getDrawPages()->getByIndex(0), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage->getCount()); + uno::Reference xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.OLE2Shape"), xShape->getShapeType()); +} + +void Chart2ExportTest2::testTdf122031() +{ + //Checks pie chart data label format. + + load(u"/chart2/qa/extras/data/xlsx/", "tdf122031.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:numFmt", + "formatCode", "0.000%"); + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[1]/c:numFmt", + "formatCode", "0.000%"); + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[2]/c:numFmt", + "formatCode", "0.000%"); + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[3]/c:numFmt", + "formatCode", "0.000%"); +} + +void Chart2ExportTest2::testTdf115012() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf115012.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + // workaround: use-zero instead of leave-gap to show the original line chart + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", "zero"); +} + +void Chart2ExportTest2::testTdf134118() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf134118.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + // workaround: use leave-gap instead of zero to show the original line chart + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:dispBlanksAs", "val", "gap"); +} + +void Chart2ExportTest2::testTdf123206_customLabelText() +{ + load(u"/chart2/qa/extras/data/docx/", "tdf123206.docx"); + + Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/" + "c:rich/a:p/a:r/a:t", + "kiscica"); +} + +void Chart2ExportTest2::testCustomLabelText() +{ + load(u"/chart2/qa/extras/data/docx/", "testCustomlabeltext.docx"); + + Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[1]/c:idx", "val", + "2"); + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[1]/c:tx/" + "c:rich/a:p/a:r[1]/a:t", + "3.5"); + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[1]/c:tx/" + "c:rich/a:p/a:r[3]/a:t", + "CustomLabel 1"); + + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[2]/c:idx", "val", + "3"); + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/" + "c:rich/a:p/a:r[1]/a:t", + "4.5"); + assertXPathContent(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/" + "c:rich/a:p/a:r[3]/a:t", + "CustomLabel 2"); +} + +void Chart2ExportTest2::testDeletedLegendEntries() +{ + load(u"/chart2/qa/extras/data/xlsx/", "deleted_legend_entry.xlsx"); + { + reload("Calc Office Open XML"); + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 1)); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); + bool bShowLegendEntry = true; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("ShowLegendEntry") >>= bShowLegendEntry); + CPPUNIT_ASSERT(!bShowLegendEntry); + } + + load(u"/chart2/qa/extras/data/xlsx/", "deleted_legend_entry2.xlsx"); + { + reload("Calc Office Open XML"); + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); + bool bShowLegendEntry = true; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("ShowLegendEntry") >>= bShowLegendEntry); + CPPUNIT_ASSERT(!bShowLegendEntry); + + Reference xChartDoc2 = getChartDocFromSheet(1, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries2(getDataSeriesFromDoc(xChartDoc2, 0)); + CPPUNIT_ASSERT(xDataSeries2.is()); + Reference xPropertySet2(xDataSeries2, uno::UNO_QUERY_THROW); + Sequence deletedLegendEntriesSeq; + CPPUNIT_ASSERT(xPropertySet2->getPropertyValue("DeletedLegendEntries") + >>= deletedLegendEntriesSeq); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), deletedLegendEntriesSeq[0]); + } +} + +void Chart2ExportTest2::testTdf60316() +{ + load(u"/chart2/qa/extras/data/pptx/", "tdf60316.pptx"); + xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + + // Without the fix in place, the shape would have had a solidFill background + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:noFill", 1); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:solidFill", 0); +} + +void Chart2ExportTest2::testTdf130225() +{ + load(u"/chart2/qa/extras/data/docx/", "piechart_deleted_legend_entry.docx"); + reload("Office Open XML Text"); + Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference xPropertySet(xDataSeries, uno::UNO_QUERY_THROW); + Sequence deletedLegendEntriesSeq; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("DeletedLegendEntries") + >>= deletedLegendEntriesSeq); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), deletedLegendEntriesSeq[0]); +} + +void Chart2ExportTest2::testTdf59857() +{ + load(u"/chart2/qa/extras/data/ods/", "tdf59857.ods"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:floor/c:spPr/a:ln/a:noFill", 1); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:floor/c:spPr/a:solidFill/a:srgbClr", "val", + "cccccc"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:backWall/c:spPr/a:ln/a:noFill", 0); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:backWall/c:spPr/a:ln/a:solidFill/a:srgbClr", + "val", "b3b3b3"); +} + +void Chart2ExportTest2::testTdf126076() +{ + load(u"/chart2/qa/extras/data/xlsx/", "auto_marker_excel10.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + // This was 12: all series exported with square markers + assertXPath( + pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:marker/c:symbol[@val='square']", 0); + // instead of skipping markers + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser/c:marker", 0); +} + +void Chart2ExportTest2::testTdf75330() +{ + load(u"/chart2/qa/extras/data/ods/", "legend_overlay.ods"); + reload("calc8"); + { + uno::Reference xChart2Doc = getChartDocFromSheet(0, mxComponent); + uno::Reference xChartDoc(xChart2Doc, uno::UNO_QUERY); + uno::Reference xLegend = xChartDoc->getLegend(); + Reference xPropertySet(xLegend, uno::UNO_QUERY_THROW); + bool bOverlay = false; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Overlay") >>= bOverlay); + CPPUNIT_ASSERT(bOverlay); + } + reload("Calc Office Open XML"); + { + uno::Reference xChart2Doc = getChartDocFromSheet(0, mxComponent); + uno::Reference xChartDoc(xChart2Doc, uno::UNO_QUERY); + uno::Reference xLegend = xChartDoc->getLegend(); + Reference xPropertySet(xLegend, uno::UNO_QUERY_THROW); + bool bOverlay = false; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Overlay") >>= bOverlay); + CPPUNIT_ASSERT(bOverlay); + } +} + +void Chart2ExportTest2::testTdf127792() +{ + load(u"/chart2/qa/extras/data/docx/", "MSO_axis_position.docx"); + { + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", + "between"); + } + { + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart2", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:valAx/c:crossBetween", "val", + "midCat"); + } +} + +void Chart2ExportTest2::testTdf131979() +{ + load(u"/chart2/qa/extras/data/ods/", "tdf131115.ods"); + { + reload("calc8"); + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference xPropertySet; + xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW); + bool blinknumberformattosource = true; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) + >>= blinknumberformattosource); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", + !blinknumberformattosource); + } + + load(u"/chart2/qa/extras/data/ods/", "tdf131979.ods"); + { + reload("calc8"); + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 0)); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference xPropertySet; + xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW); + bool blinknumberformattosource = true; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) + >>= blinknumberformattosource); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", + blinknumberformattosource); + } +} + +void Chart2ExportTest2::testTdf132076() +{ + { + load(u"/chart2/qa/extras/data/ods/", "tdf132076.ods"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:numFmt", "formatCode", + "dd"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:catAx/c:numFmt", "sourceLinked", + "0"); + } + { + load(u"/chart2/qa/extras/data/xlsx/", "tdf132076.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:numFmt", "formatCode", + "dd"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:numFmt", "sourceLinked", + "0"); + } +} + +void Chart2ExportTest2::testTdf125812() +{ + load(u"/chart2/qa/extras/data/odp/", "ellipticalGradientFill.odp"); + xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress MS PowerPoint 2007 XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path", "path", + "circle"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", + "l", "50000"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", + "t", "49000"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", + "r", "50000"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:spPr/a:gradFill/a:path/a:fillToRect", + "b", "51000"); +} + +void Chart2ExportTest2::testTdf133190() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf133190_tdf133191.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + // Test word wrap of data point label + assertXPath( + pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[1]/c:txPr/a:bodyPr", + "wrap", "none"); + assertXPath( + pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[2]/c:txPr/a:bodyPr", + "wrap", "square"); +} + +void Chart2ExportTest2::testTdf133191() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf133190_tdf133191.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + // Test rotation of data point label + assertXPath( + pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:dLbl[3]/c:txPr/a:bodyPr", + "rot", "-4500000"); +} + +void Chart2ExportTest2::testTdf132594() +{ + load(u"/chart2/qa/extras/data/xlsx/", "chart_pie2007.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:cat", 1); +} + +void Chart2ExportTest2::testTdf134255() +{ + load(u"/chart2/qa/extras/data/docx/", "tdf134255.docx"); + Reference xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xChartDoc.is()); + + // import test + Reference xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference xPropSet(xDataSeries, UNO_QUERY_THROW); + bool bWrap = false; + CPPUNIT_ASSERT((xPropSet->getPropertyValue("TextWordWrap") >>= bWrap)); + CPPUNIT_ASSERT(bWrap); + + // export test + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:pieChart/c:ser/c:dLbls/c:txPr/a:bodyPr", "wrap", + "square"); +} + +void Chart2ExportTest2::testTdf134977() +{ + load(u"/chart2/qa/extras/data/xlsx/", "custom_data_label.xlsx"); + + //import test + uno::Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + Reference xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); + CPPUNIT_ASSERT(xDataSeries.is()); + uno::Reference xPropertySet(xDataSeries->getDataPointByIndex(0), + uno::UNO_SET_THROW); + uno::Sequence> aFields; + float nFontSize; + xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; + aFields[0]->getPropertyValue("CharHeight") >>= nFontSize; + CPPUNIT_ASSERT_EQUAL(static_cast(9), nFontSize); + + //export test + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl/c:tx/c:rich/a:p/" + "a:r/a:rPr", + "sz", "900"); +} + +void Chart2ExportTest2::testTdf123647() +{ + load(u"/chart2/qa/extras/data/xlsx/", "empty_chart.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart", 1); +} + +void Chart2ExportTest2::testTdf136267() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf136267.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPathContent( + pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:cat/c:strRef/c:strCache/c:pt/c:v", + "John"); +} + +void Chart2ExportTest2::testDataLabelPlacementPieChart() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf134978.xlsx"); + reload("calc8"); + uno::Reference xChartDoc(getChartCompFromSheet(0, mxComponent), + UNO_QUERY_THROW); + // test the placement of the manually positioned label + Reference xDataPointPropSet( + xChartDoc->getDiagram()->getDataPointProperties(2, 0), uno::UNO_SET_THROW); + uno::Any aAny = xDataPointPropSet->getPropertyValue("LabelPlacement"); + CPPUNIT_ASSERT(aAny.hasValue()); + sal_Int32 nLabelPlacement = 0; + CPPUNIT_ASSERT(aAny >>= nLabelPlacement); + CPPUNIT_ASSERT_EQUAL(chart::DataLabelPlacement::OUTSIDE, nLabelPlacement); +} + +void Chart2ExportTest2::testTdf137917() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf137917.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:baseTimeUnit", "val", "days"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:majorUnit", "val", "1"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:majorTimeUnit", "val", + "months"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:minorUnit", "val", "7"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dateAx/c:minorTimeUnit", "val", + "days"); +} + +void Chart2ExportTest2::testTdf138204() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf138204.xlsx"); + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + + // Check the first data label field type + assertXPath( + pXmlDoc, + "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLbl/c:tx/c:rich/a:p/a:fld", + "type", "CELLRANGE"); + + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + + uno::Reference xDataSeries(getDataSeriesFromDoc(xChartDoc, 1)); + CPPUNIT_ASSERT(xDataSeries.is()); + + uno::Reference xPropertySet; + uno::Sequence> aFields; + xPropertySet.set(xDataSeries->getDataPointByIndex(0), uno::UNO_SET_THROW); + xPropertySet->getPropertyValue("CustomLabelFields") >>= aFields; + CPPUNIT_ASSERT_EQUAL(static_cast(1), aFields.getLength()); + + CPPUNIT_ASSERT_EQUAL( + chart2::DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_CELLRANGE, + aFields[0]->getFieldType()); + //CPPUNIT_ASSERT_EQUAL(OUString("67.5%"), aFields[0]->getString()); TODO: Not implemented yet +} + +void Chart2ExportTest2::testTdf138181() +{ + load(u"/chart2/qa/extras/data/xlsx/", "piechart_deleted_legendentry.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 xLegendEntry1, xLegendEntry2, xLegendEntry3; + + // first legend entry is visible + xLegendEntry1 + = getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=0:Point=0:LegendEntry=0"); + CPPUNIT_ASSERT(xLegendEntry1.is()); + + // second legend entry is not visible + xLegendEntry2 + = getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=0:Point=1:LegendEntry=0"); + CPPUNIT_ASSERT(!xLegendEntry2.is()); + + // third legend entry is visible + xLegendEntry3 + = getShapeByName(xShapes, "CID/MultiClick/D=0:CS=0:CT=0:Series=0:Point=2:LegendEntry=0"); + CPPUNIT_ASSERT(xLegendEntry3.is()); +} + +void Chart2ExportTest2::testCustomShapeText() +{ + load(u"/chart2/qa/extras/data/ods/", "tdf72776.ods"); + reload("calc8"); + Reference xChartDoc(getChartDocFromSheet(0, mxComponent), + UNO_QUERY_THROW); + // test that the text of custom shape exists inside the chart + 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()); + + Reference xRange(xCustomShape, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(!xRange->getString().isEmpty()); +} + +void Chart2ExportTest2::testuserShapesXLSX() +{ + load(u"/chart2/qa/extras/data/xlsx/", "tdf128621.xlsx"); + reload("Calc Office Open XML"); + + Reference xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + + // test that the custom shape exists + 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()); + // test type of shape + CPPUNIT_ASSERT(xCustomShape->getShapeType().endsWith("CustomShape")); + // test custom shape position + awt::Point aPosition = xCustomShape->getPosition(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1356, aPosition.X, 300); + CPPUNIT_ASSERT_DOUBLES_EQUAL(9107, aPosition.Y, 300); + // test custom shape size + awt::Size aSize = xCustomShape->getSize(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(9520, aSize.Width, 300); + CPPUNIT_ASSERT_DOUBLES_EQUAL(1805, aSize.Height, 300); + // test custom shape text + Reference xRange(xCustomShape, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(!xRange->getString().isEmpty()); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest2); + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/qa/extras/chart2geometry.cxx b/chart2/qa/extras/chart2geometry.cxx index d6c243ccfd76..c1fe65fa927d 100644 --- a/chart2/qa/extras/chart2geometry.cxx +++ b/chart2/qa/extras/chart2geometry.cxx @@ -28,7 +28,7 @@ using uno::Reference; using beans::XPropertySet; -class Chart2GeometryTest : public ChartTest, public XmlTestTools +class Chart2GeometryTest : public ChartTest { protected: virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override; @@ -71,72 +71,8 @@ public: CPPUNIT_TEST(testTdf135366_CustomLabelText); CPPUNIT_TEST_SUITE_END(); - -protected: - /** - * Given that some problem doesn't affect the result in the importer, we - * test the resulting file directly, by opening the zip file, parsing an - * xml stream, and asserting an XPath expression. This method returns the - * xml stream, so that you can do the asserting. - */ - xmlDocUniquePtr parseExport(const OUString& rDir, const OUString& rFilterFormat); }; -namespace -{ -// This is copied from Chart2ExportTest. It allows to access the chart from a MS Office document -// without knowing whether the file is a chart1.xml or chart2.xml... As of August 2020, Calc -// and Impress use a static variable for the number and therefore the number depends on whether -// there had already been savings before. -struct CheckForChartName -{ -private: - OUString aDir; - -public: - explicit CheckForChartName(const OUString& rDir) - : aDir(rDir) - { - } - - bool operator()(const OUString& rName) - { - if (!rName.startsWith(aDir)) - return false; - - if (!rName.endsWith(".xml")) - return false; - - return true; - } -}; - -OUString findChartFile(const OUString& rDir, uno::Reference const& xNames) -{ - uno::Sequence aNames = xNames->getElementNames(); - OUString* pElement = std::find_if(aNames.begin(), aNames.end(), CheckForChartName(rDir)); - - CPPUNIT_ASSERT(pElement != aNames.end()); - return *pElement; -} -} - -xmlDocUniquePtr Chart2GeometryTest::parseExport(const OUString& rDir, const OUString& rFilterFormat) -{ - std::shared_ptr pTempFile = save(rFilterFormat); - - // Read the XML stream we're interested in. - uno::Reference xNameAccess - = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), - pTempFile->GetURL()); - uno::Reference xInputStream( - xNameAccess->getByName(findChartFile(rDir, xNameAccess)), uno::UNO_QUERY); - CPPUNIT_ASSERT(xInputStream.is()); - std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); - - return parseXmlStream(pStream.get()); -} - void Chart2GeometryTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) { XmlTestTools::registerOOXMLNamespaces(pXmlXPathCtx); diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx index 8dcdcf98bc50..0a7b00cc884e 100644 --- a/chart2/qa/extras/charttest.hxx +++ b/chart2/qa/extras/charttest.hxx @@ -10,6 +10,7 @@ #pragma once #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include @@ -60,6 +62,8 @@ #include #include +#include + using namespace css; using namespace css::uno; @@ -68,7 +72,41 @@ namespace com::sun::star::chart2 { class XDiagram; } namespace com::sun::star::table { class XTableCharts; } namespace com::sun::star::table { class XTablePivotCharts; } -class ChartTest : public test::BootstrapFixture, public unotest::MacrosTest +namespace { + +struct CheckForChartName +{ +private: + OUString aDir; + +public: + explicit CheckForChartName( const OUString& rDir ): + aDir(rDir) {} + + bool operator()(const OUString& rName) + { + if(!rName.startsWith(aDir)) + return false; + + if(!rName.endsWith(".xml")) + return false; + + return true; + } +}; + +OUString findChartFile(const OUString& rDir, uno::Reference< container::XNameAccess > const & xNames ) +{ + uno::Sequence aNames = xNames->getElementNames(); + OUString* pElement = std::find_if(aNames.begin(), aNames.end(), CheckForChartName(rDir)); + + CPPUNIT_ASSERT(pElement != aNames.end()); + return *pElement; +} + +} + +class ChartTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools { public: ChartTest():mbSkipValidation(false) {} @@ -93,6 +131,14 @@ protected: Reference< lang::XComponent > mxComponent; OUString maServiceName; bool mbSkipValidation; // if you set this flag for a new test I'm going to haunt you! + + /** + * Given that some problem doesn't affect the result in the importer, we + * test the resulting file directly, by opening the zip file, parsing an + * xml stream, and asserting an XPath expression. This method returns the + * xml stream, so that you can do the asserting. + */ + xmlDocUniquePtr parseExport(const OUString& rDir, const OUString& rFilterFormat); }; OUString ChartTest::getFileExtension( const OUString& aFileName ) @@ -639,4 +685,17 @@ getShapeByName(const uno::Reference& rShapes, const OUString& return uno::Reference(); } +xmlDocUniquePtr ChartTest::parseExport(const OUString& rDir, const OUString& rFilterFormat) +{ + std::shared_ptr pTempFile = save(rFilterFormat); + + // Read the XML stream we're interested in. + uno::Reference xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), pTempFile->GetURL()); + uno::Reference xInputStream(xNameAccess->getByName(findChartFile(rDir, xNameAccess)), uno::UNO_QUERY); + CPPUNIT_ASSERT(xInputStream.is()); + std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); + + return parseXmlStream(pStream.get()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/qa/extras/xshape/chart2xshape.cxx b/chart2/qa/extras/xshape/chart2xshape.cxx index 70b9a80770b4..895f84bb62a4 100644 --- a/chart2/qa/extras/xshape/chart2xshape.cxx +++ b/chart2/qa/extras/xshape/chart2xshape.cxx @@ -18,7 +18,7 @@ #include #include -class Chart2XShapeTest : public ChartTest, public XmlTestTools +class Chart2XShapeTest : public ChartTest { public: void testFdo75075();