From 366812f72f73c12e5be83d27409272769e9337f2 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Wed, 8 Mar 2023 10:01:51 +0100 Subject: UnoApiXmlTest: remove workaround to handle chart file names in tests No longer needed after 269585d6b461b565fe75f77b6dbf219749edc5ab "oox, sd: fix ever-increasing chart IDs when exporting to PPTX" and b27b250f70f4651d387ef0646a9668950371e779 "sc: fix ever-increasing chart IDs when exporting to XLSX" Also restored the documents modified in d913584909c2e0a235546a5f800baf45c3446d8b "UnoApiXmlTest: merge parseExport from ChartTest" to ensure only one chart was possible per document. Sample documents in unittests can have more than one chart now, since the chart file name wouldn't change Kudos to Miklos Vajna for fixing the chart file names when exporting them Change-Id: I10e2c44e41953a2d0d08bbb2a813134861e74660 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148461 Tested-by: Xisco Fauli Reviewed-by: Xisco Fauli --- test/source/unoapixml_test.cxx | 47 +++--------------------------------------- 1 file changed, 3 insertions(+), 44 deletions(-) (limited to 'test/source') diff --git a/test/source/unoapixml_test.cxx b/test/source/unoapixml_test.cxx index c80ceb616665..23dc826cbc97 100644 --- a/test/source/unoapixml_test.cxx +++ b/test/source/unoapixml_test.cxx @@ -11,13 +11,9 @@ #include #include -#include #include #include -#include -#include - #include #include #include @@ -32,46 +28,9 @@ UnoApiXmlTest::UnoApiXmlTest(OUString path) xmlDocUniquePtr UnoApiXmlTest::parseExport(OUString const& rStreamName) { - if (rStreamName.indexOf("chart") == -1) - { - std::unique_ptr const pStream( - parseExportStream(maTempFile.GetURL(), rStreamName)); - xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); - return pXmlDoc; - } - else - { - // we have a static counter that increments chart export file names. So - // only the first exported file gets the file name chart1.xml and all the - // following charts are incremented by one even if they are in a different file. - OUString aStreamName(rStreamName); - uno::Reference xNameAccess - = packages::zip::ZipFileAccess::createWithURL( - comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); - const uno::Sequence aNames = xNameAccess->getElementNames(); - - if (aStreamName.endsWith(".xml")) - // remove "1.xml" - aStreamName = aStreamName.copy(0, aStreamName.getLength() - 5); - - uno::Reference xInputStream; - - int nCount = 0; - for (const auto& rElementName : aNames) - { - if (o3tl::starts_with(rElementName, aStreamName)) - { - xInputStream.set(xNameAccess->getByName(rElementName), uno::UNO_QUERY); - ++nCount; - assert(nCount == 1 && "Only use one chart per document"); - } - } - - CPPUNIT_ASSERT(xInputStream.is()); - std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); - - return parseXmlStream(pStream.get()); - } + std::unique_ptr const pStream(parseExportStream(maTempFile.GetURL(), rStreamName)); + xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + return pXmlDoc; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit