From be63419810cd6f418d33ef1b7724ba32e867e52b Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Thu, 3 Nov 2022 13:01:06 +0100 Subject: qa: remove duplicated code Change-Id: I13da5ca9d07131a340dcf95ca0b980d75ca6e9d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142229 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- xmloff/qa/unit/draw.cxx | 8 +------- xmloff/qa/unit/style.cxx | 8 +------- xmloff/qa/unit/text.cxx | 44 +++++--------------------------------------- 3 files changed, 7 insertions(+), 53 deletions(-) (limited to 'xmloff/qa') diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index 93b230db8d72..1f41afbba3ed 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -91,12 +90,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf141301_Extrusion_Angle) // Prepare use of XPath utl::TempFileNamed aTempFile = save("draw8"); - uno::Reference xNameAccess - = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, aTempFile.GetURL()); - uno::Reference xInputStream(xNameAccess->getByName("content.xml"), - uno::UNO_QUERY); - std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); - xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); // Without fix draw:extrusion-skew="50 -135" was not written to file although "50 -135" is not // default in ODF, but only default inside LO. diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx index f5b42fac1fb0..a51b55b37818 100644 --- a/xmloff/qa/unit/style.cxx +++ b/xmloff/qa/unit/style.cxx @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -89,12 +88,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFontSorting) utl::TempFileNamed aTempFile = save("writer8"); // Then make sure elements are sorted (by style:name="..."): - uno::Reference xNameAccess - = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, aTempFile.GetURL()); - uno::Reference xInputStream(xNameAccess->getByName("content.xml"), - uno::UNO_QUERY); - std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); - xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); xmlXPathObjectPtr pXPath = getXPathNode(pXmlDoc, "/office:document-content/office:font-face-decls/style:font-face"); xmlNodeSetPtr pXmlNodes = pXPath->nodesetval; diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index 7a78848c4b7a..64ec2500ad9f 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -152,25 +151,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testParaStyleListLevel) CPPUNIT_ASSERT_EQUAL(static_cast(1), nNumberingLevel); // Test the export as well: - - // Given a doc model that has a para style with NumberingLevel=2: - uno::Reference xStorable(mxComponent, uno::UNO_QUERY); - - // When exporting that to ODT: - uno::Sequence aStoreProps = comphelper::InitPropertySequence({ - { "FilterName", uno::Any(OUString("writer8")) }, - }); - utl::TempFileNamed aTempFile; - aTempFile.EnableKillingFile(); - xStorable->storeToURL(aTempFile.GetURL(), aStoreProps); + utl::TempFileNamed aTempFile = save("writer8"); // Then make sure we save the style's numbering level: - uno::Reference xNameAccess - = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, aTempFile.GetURL()); - uno::Reference xInputStream(xNameAccess->getByName("styles.xml"), - uno::UNO_QUERY); - std::unique_ptr pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); - xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "styles.xml"); // Without the accompanying fix in place, this failed with: // - XPath '/office:document-styles/office:styles/style:style[@style:name='mystyle']' no attribute 'list-level' exist // i.e. a custom NumberingLevel was lost on save. @@ -206,13 +190,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testListId) loadFromURL(u"list-id.fodt"); // When storing that document as ODF: - uno::Reference xStorable(mxComponent, uno::UNO_QUERY); - uno::Sequence aStoreProps = comphelper::InitPropertySequence({ - { "FilterName", uno::Any(OUString("writer8")) }, - }); - utl::TempFileNamed aTempFile; - aTempFile.EnableKillingFile(); - xStorable->storeToURL(aTempFile.GetURL(), aStoreProps); + utl::TempFileNamed aTempFile = save("writer8"); // Then make sure that unreferenced xml:id="..." attributes are not written: xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); @@ -307,13 +285,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testRelativeWidth) // Body frame width is 16cm. xStyle->setPropertyValue("Width", uno::Any(static_cast(20000))); - uno::Reference xStorable(mxComponent, uno::UNO_QUERY); - uno::Sequence aStoreProps = comphelper::InitPropertySequence({ - { "FilterName", uno::Any(OUString("writer8")) }, - }); - utl::TempFileNamed aTempFile; - aTempFile.EnableKillingFile(); - xStorable->storeToURL(aTempFile.GetURL(), aStoreProps); + utl::TempFileNamed aTempFile = save("writer8"); xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); // Without the accompanying fix in place, this failed with: @@ -343,13 +315,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testScaleWidthAndHeight) xText->insertTextContent(xCursor, xTextFrame, /*bAbsorb=*/false); // When exporting to ODT: - uno::Reference xStorable(mxComponent, uno::UNO_QUERY); - uno::Sequence aStoreProps = comphelper::InitPropertySequence({ - { "FilterName", uno::Any(OUString("writer8")) }, - }); - utl::TempFileNamed aTempFile; - aTempFile.EnableKillingFile(); - xStorable->storeToURL(aTempFile.GetURL(), aStoreProps); + utl::TempFileNamed aTempFile = save("writer8"); // Then make sure that we still export a non-zero size: xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); -- cgit