summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-05-10 11:10:59 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-05-10 12:07:10 +0200
commit0a6db8c2d6fdf5cb2dfad9381f82f730021a9a9d (patch)
tree44add453ee928f440dcda00e86ce59a8a27e8f9d /chart2
parent5582b8c6da7e9d8cbcf20b381a8b0f5344b4d743 (diff)
chart2: remove duplicated code
Change-Id: I1bd92230e9fba8b562e57dbc3e269913dc3942e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151605 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2import.cxx12
-rw-r--r--chart2/qa/extras/chart2import2.cxx6
-rw-r--r--chart2/qa/extras/charttest.hxx25
3 files changed, 14 insertions, 29 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 776c6e706bd9..fc5caf42c3a7 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -342,7 +342,8 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testDOCXChartValuesSize)
CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPPTChartSeries)
{
//test chart series names for ppt
- uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions(u"/chart2/qa/extras/data/ppt/", "chart.ppt");
+ loadFromURL(u"ppt/chart.ppt");
+ uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions(0, 0);
CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
@@ -573,7 +574,8 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testPPTXStackedNonStackedYAxis)
CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testODPChartSeries)
{
//test chart series names for odp
- uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions(u"/chart2/qa/extras/data/odp/", "chart.odp");
+ loadFromURL(u"odp/chart.odp");
+ uno::Sequence < OUString > seriesList = getImpressChartColumnDescriptions(0, 0);
CPPUNIT_ASSERT_EQUAL(OUString("Column 1"), seriesList[0]);
CPPUNIT_ASSERT_EQUAL(OUString("Column 2"), seriesList[1]);
CPPUNIT_ASSERT_EQUAL(OUString("Column 3"), seriesList[2]);
@@ -582,7 +584,8 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testODPChartSeries)
CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testBnc864396)
{
- uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromImpress(u"/chart2/qa/extras/data/pptx/", "bnc864396.pptx"), uno::UNO_QUERY_THROW);
+ loadFromURL(u"pptx/bnc864396.pptx");
+ uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0,0), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider());
uno::Reference< chart2::XInternalDataProvider > xDataProvider( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
@@ -1584,7 +1587,8 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTdf140489MultiSeriesChartAxisXLSX)
CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testInternalDataProvider)
{
- uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromImpress(u"/chart2/qa/extras/data/odp/", "chart.odp"), uno::UNO_QUERY_THROW);
+ loadFromURL(u"odp/chart.odp");
+ uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromDrawImpress(0,0), uno::UNO_QUERY_THROW);
const uno::Reference< chart2::data::XDataProvider >& rxDataProvider = xChartDoc->getDataProvider();
// Parse 42 array
diff --git a/chart2/qa/extras/chart2import2.cxx b/chart2/qa/extras/chart2import2.cxx
index 16be602d3deb..156dff2142bf 100644
--- a/chart2/qa/extras/chart2import2.cxx
+++ b/chart2/qa/extras/chart2import2.cxx
@@ -365,9 +365,9 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf123206CustomLabelField)
// File contains the deprecated "custom-label-field" attribute of the
// "data-point" element. It should be interpreted and stored as a data point
// property.
- uno::Reference<chart2::XChartDocument> xChartDoc(
- getChartDocFromImpress(u"/chart2/qa/extras/data/odp/", "tdf123206.odp"),
- uno::UNO_QUERY_THROW);
+ loadFromURL(u"odp/tdf123206.odp");
+ uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 0),
+ uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
CPPUNIT_ASSERT(xChartDoc.is());
Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index 06fda08fe46f..db416affaa9f 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -80,9 +80,7 @@ public:
{
}
- uno::Sequence < OUString > getImpressChartColumnDescriptions( std::u16string_view pDir, const char* pName );
-
- uno::Reference< chart::XChartDocument > getChartDocFromImpress( std::u16string_view pDir, const char* pName );
+ uno::Sequence < OUString > getImpressChartColumnDescriptions(sal_Int32 nPage, sal_Int32 nShape);
uno::Reference<chart::XChartDocument> getChartDocFromDrawImpress( sal_Int32 nPage, sal_Int32 nShape );
uno::Reference<chart::XChartDocument> getChartDocFromDrawImpressNamed( sal_Int32 nPage, std::u16string_view rName);
@@ -388,23 +386,6 @@ std::vector<uno::Sequence<uno::Any> > getDataSeriesLabelsFromChartType( const Re
return aRet;
}
-uno::Reference< chart::XChartDocument > ChartTest::getChartDocFromImpress( std::u16string_view pDir, const char* pName )
-{
- mxComponent = loadFromDesktop(m_directories.getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.comp.Draw.PresentationDocument");
- uno::Reference< drawing::XDrawPagesSupplier > xDoc(mxComponent, uno::UNO_QUERY_THROW );
- uno::Reference< drawing::XDrawPage > xPage(
- xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
- uno::Reference< beans::XPropertySet > xShapeProps(
- xPage->getByIndex(0), uno::UNO_QUERY );
- CPPUNIT_ASSERT(xShapeProps.is());
- uno::Reference< frame::XModel > xDocModel;
- xShapeProps->getPropertyValue("Model") >>= xDocModel;
- CPPUNIT_ASSERT(xDocModel.is());
- uno::Reference< chart::XChartDocument > xChartDoc( xDocModel, uno::UNO_QUERY_THROW );
-
- return xChartDoc;
-}
-
uno::Reference<chart::XChartDocument> ChartTest::getChartDocFromDrawImpress(
sal_Int32 nPage, sal_Int32 nShape )
{
@@ -486,9 +467,9 @@ uno::Reference<chart::XChartDocument> ChartTest::getChartDocFromWriter( sal_Int3
return xChartDoc;
}
-uno::Sequence < OUString > ChartTest::getImpressChartColumnDescriptions( std::u16string_view pDir, const char* pName )
+uno::Sequence < OUString > ChartTest::getImpressChartColumnDescriptions(sal_Int32 nPage, sal_Int32 nShape)
{
- uno::Reference< chart::XChartDocument > xChartDoc = getChartDocFromImpress( pDir, pName );
+ uno::Reference< chart::XChartDocument > xChartDoc = getChartDocFromDrawImpress( nPage, nShape );
uno::Reference< chart::XChartDataArray > xChartData ( xChartDoc->getData(), uno::UNO_QUERY_THROW);
uno::Sequence < OUString > seriesList = xChartData->getColumnDescriptions();
return seriesList;