summaryrefslogtreecommitdiff
path: root/xmloff/qa
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-11-03 13:01:06 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-11-03 18:32:28 +0100
commitbe63419810cd6f418d33ef1b7724ba32e867e52b (patch)
tree82f28f263b2ef9205825e8f12ba71b62429f89fb /xmloff/qa
parent57e0b4344111431e0a26622920b35dfc7d9e8ff8 (diff)
qa: remove duplicated code
Change-Id: I13da5ca9d07131a340dcf95ca0b980d75ca6e9d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142229 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'xmloff/qa')
-rw-r--r--xmloff/qa/unit/draw.cxx8
-rw-r--r--xmloff/qa/unit/style.cxx8
-rw-r--r--xmloff/qa/unit/text.cxx44
3 files changed, 7 insertions, 53 deletions
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 <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XStorable.hpp>
-#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeMetalType.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
@@ -91,12 +90,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf141301_Extrusion_Angle)
// Prepare use of XPath
utl::TempFileNamed aTempFile = save("draw8");
- uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
- = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, aTempFile.GetURL());
- uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName("content.xml"),
- uno::UNO_QUERY);
- std::unique_ptr<SvStream> 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 <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/frame/XStorable.hpp>
-#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
@@ -89,12 +88,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFontSorting)
utl::TempFileNamed aTempFile = save("writer8");
// Then make sure <style:font-face> elements are sorted (by style:name="..."):
- uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
- = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, aTempFile.GetURL());
- uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName("content.xml"),
- uno::UNO_QUERY);
- std::unique_ptr<SvStream> 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 <com/sun/star/text/BibliographyDataType.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
-#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
#include <comphelper/propertysequence.hxx>
#include <comphelper/propertyvalue.hxx>
@@ -152,25 +151,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testParaStyleListLevel)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), nNumberingLevel);
// Test the export as well:
-
- // Given a doc model that has a para style with NumberingLevel=2:
- uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
-
- // When exporting that to ODT:
- uno::Sequence<beans::PropertyValue> 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<packages::zip::XZipFileAccess2> xNameAccess
- = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, aTempFile.GetURL());
- uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName("styles.xml"),
- uno::UNO_QUERY);
- std::unique_ptr<SvStream> 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<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> 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<sal_Int32>(20000)));
- uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> 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<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> 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");