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>
This commit is contained in:
Xisco Fauli
2022-11-03 13:01:06 +01:00
parent 57e0b43441
commit be63419810
4 changed files with 8 additions and 58 deletions

View File

@ -76,11 +76,7 @@ CPPUNIT_TEST_FIXTURE(MiscTest, testODFCustomMetadata)
xProps->storeToMedium(aTempFile.GetURL(), mimeArgs);
// check that custom metadata is preserved
uno::Reference<packages::zip::XZipFileAccess2> const xZip(
packages::zip::ZipFileAccess::createWithURL(m_xContext, aTempFile.GetURL()));
uno::Reference<io::XInputStream> const xInputStream(xZip->getByName("meta.xml"), uno::UNO_QUERY);
std::unique_ptr<SvStream> const pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get());
xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "meta.xml");
assertXPathContent(pXmlDoc, "/office:document-meta/office:meta/bork", "bork");
assertXPath(pXmlDoc, "/office:document-meta/office:meta/foo:bar", 1);
assertXPath(pXmlDoc, "/office:document-meta/office:meta/foo:bar/baz:foo", 1);

View File

@ -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.

View File

@ -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;

View File

@ -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");