diff options
-rw-r--r-- | filter/qa/unit/svg.cxx | 96 | ||||
-rw-r--r-- | include/test/unoapixml_test.hxx | 7 | ||||
-rw-r--r-- | sw/qa/extras/fodfexport/fodfexport.cxx | 36 | ||||
-rw-r--r-- | sw/qa/inc/swmodeltestbase.hxx | 7 | ||||
-rw-r--r-- | sw/qa/unit/swmodeltestbase.cxx | 6 | ||||
-rw-r--r-- | test/source/unoapixml_test.cxx | 6 |
6 files changed, 53 insertions, 105 deletions
diff --git a/filter/qa/unit/svg.cxx b/filter/qa/unit/svg.cxx index 8e4f5f5130a4..30a47557f9bb 100644 --- a/filter/qa/unit/svg.cxx +++ b/filter/qa/unit/svg.cxx @@ -19,6 +19,7 @@ #include <com/sun/star/text/ControlCharacter.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <comphelper/propertyvalue.hxx> #include <unotools/streamwrap.hxx> #include <unotools/mediadescriptor.hxx> #include <tools/stream.hxx> @@ -53,18 +54,13 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testPreserveJpg) dispatchCommand(mxComponent, ".uno:JumpToNextFrame", {}); // Export the selection to SVG. - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY_THROW); - SvMemoryStream aStream; - uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aStream); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("writer_svg_Export"); - aMediaDescriptor["SelectionOnly"] <<= true; - aMediaDescriptor["OutputStream"] <<= xOut; - xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); - aStream.Seek(STREAM_SEEK_TO_BEGIN); + saveWithParams({ + comphelper::makePropertyValue("FilterName", u"writer_svg_Export"_ustr), + comphelper::makePropertyValue("SelectionOnly", true), + }); // Make sure that the original JPG data is reused and we don't perform a PNG re-compress. - xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); + xmlDocUniquePtr pXmlDoc = parseExportedFile(); OUString aAttributeValue = getXPath(pXmlDoc, "//svg:image"_ostr, "href"_ostr); // Without the accompanying fix in place, this test would have failed with: @@ -81,17 +77,10 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentLine) loadFromFile(u"semi-transparent-line.odg"); // Export it to SVG. - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY_THROW); - SvMemoryStream aStream; - uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aStream); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("draw_svg_Export"); - aMediaDescriptor["OutputStream"] <<= xOut; - xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); - aStream.Seek(STREAM_SEEK_TO_BEGIN); + save("draw_svg_Export"); // Get the style of the group around the actual <path> element. - xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); + xmlDocUniquePtr pXmlDoc = parseExportedFile(); OUString aStyle = getXPath( pXmlDoc, "//svg:g[@class='com.sun.star.drawing.LineShape']/svg:g/svg:g"_ostr, "style"_ostr); // Without the accompanying fix in place, this test would have failed, as the style was @@ -108,17 +97,10 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentFillWithTransparentLine) loadFromFile(u"semi-transparent-fill.odg"); // Export it to SVG. - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY_THROW); - SvMemoryStream aStream; - uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aStream); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("draw_svg_Export"); - aMediaDescriptor["OutputStream"] <<= xOut; - xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); - aStream.Seek(STREAM_SEEK_TO_BEGIN); + save("draw_svg_Export"); // Get the style of the group around the actual <path> element. - xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); + xmlDocUniquePtr pXmlDoc = parseExportedFile(); OUString aStyle = getXPath(pXmlDoc, "//svg:g[@class='com.sun.star.drawing.EllipseShape']/svg:g/svg:g"_ostr, "style"_ostr); @@ -146,18 +128,9 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentText) loadFromFile(u"TransparentText.odg"); // Export to SVG. - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY_THROW); - - SvMemoryStream aStream; - uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aStream); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("draw_svg_Export"); - aMediaDescriptor["OutputStream"] <<= xOut; - xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); - aStream.Seek(STREAM_SEEK_TO_BEGIN); - - xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); + save("draw_svg_Export"); + xmlDocUniquePtr pXmlDoc = parseExportedFile(); // We expect 2 groups of class "TextShape" that // have some svg:text node inside. // Without the accompanying fix in place, this test would have failed with: @@ -198,17 +171,10 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentMultiParaText) xShapeProps->setPropertyValue("CharTransparence", uno::Any(static_cast<sal_Int16>(20))); // When exporting to SVG: - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY_THROW); - SvMemoryStream aStream; - uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aStream); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("draw_svg_Export"); - aMediaDescriptor["OutputStream"] <<= xOut; - xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); - aStream.Seek(STREAM_SEEK_TO_BEGIN); + save("draw_svg_Export"); // Then make sure that the two semi-transparent paragraphs have the same X position: - xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); + xmlDocUniquePtr pXmlDoc = parseExportedFile(); assertXPath(pXmlDoc, "(//svg:g[@class='TextShape']//svg:tspan[@class='TextPosition'])[1]"_ostr, "x"_ostr, "250"); assertXPath(pXmlDoc, @@ -250,17 +216,10 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testCustomBullet) loadFromFile(u"custom-bullet.fodp"); // When exporting that to SVG: - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY_THROW); - SvMemoryStream aStream; - uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aStream); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export"); - aMediaDescriptor["OutputStream"] <<= xOut; - xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); + save("impress_svg_Export"); // Then make sure the bullet glyph is not lost: - aStream.Seek(STREAM_SEEK_TO_BEGIN); - xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); + xmlDocUniquePtr pXmlDoc = parseExportedFile(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 // - Actual : 0 @@ -278,17 +237,9 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, attributeRedefinedTest) loadFromFile(u"attributeRedefinedTest.odp"); // Export to SVG. - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY_THROW); - SvMemoryStream aStream; - uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aStream); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export"); - aMediaDescriptor["OutputStream"] <<= xOut; - xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); - aStream.Seek(STREAM_SEEK_TO_BEGIN); - - xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); + save("impress_svg_Export"); + xmlDocUniquePtr pXmlDoc = parseExportedFile(); // We expect four paragraph // 2 empty paragraphs with ids // 2 paragraphs with text @@ -331,17 +282,10 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testTab) xShapeText->setString("A\tB"); // When exporting that document to SVG: - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY_THROW); - SvMemoryStream aStream; - uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aStream); - utl::MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export"); - aMediaDescriptor["OutputStream"] <<= xOut; - xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); + save("impress_svg_Export"); // Then make sure the tab is not lost: - aStream.Seek(STREAM_SEEK_TO_BEGIN); - xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); + xmlDocUniquePtr pXmlDoc = parseExportedFile(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 2 // - Actual : 1 diff --git a/include/test/unoapixml_test.hxx b/include/test/unoapixml_test.hxx index 660fda6c2050..569be11790b9 100644 --- a/include/test/unoapixml_test.hxx +++ b/include/test/unoapixml_test.hxx @@ -23,6 +23,13 @@ public: UnoApiXmlTest(OUString path); xmlDocUniquePtr parseExport(OUString const& rStreamName); + + /** + * Returns an xml stream of an exported file. + * To be used when the exporter doesn't create zip archives, but single files + * (like Flat ODF Export) + */ + xmlDocUniquePtr parseExportedFile(); }; #endif // INCLUDED_TEST_UNOAPIXML_TEST_HXX diff --git a/sw/qa/extras/fodfexport/fodfexport.cxx b/sw/qa/extras/fodfexport/fodfexport.cxx index 4d4ff5f0b047..eefb35c6395e 100644 --- a/sw/qa/extras/fodfexport/fodfexport.cxx +++ b/sw/qa/extras/fodfexport/fodfexport.cxx @@ -22,34 +22,38 @@ public: } }; -DECLARE_FODFEXPORT_TEST(testTdf113696, "tdf113696.odt") +CPPUNIT_TEST_FIXTURE(Test, testTdf113696) { + loadFromFile(u"tdf113696.odt"); + CPPUNIT_ASSERT_EQUAL(1, getShapes()); CPPUNIT_ASSERT_EQUAL(1, getPages()); + + save("OpenDocument Text Flat XML"); // Test that an image which is written in svm format (image/x-vclgraphic) // is accompanied by a png fallback graphic. - if (xmlDocUniquePtr pXmlDoc = parseExportedFile()) - { - assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" - "draw:image[@draw:mime-type='image/x-vclgraphic']"_ostr); - assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" - "draw:image[@draw:mime-type='image/png']"_ostr); - } + xmlDocUniquePtr pXmlDoc = parseExportedFile(); + assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" + "draw:image[@draw:mime-type='image/x-vclgraphic']"_ostr); + assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" + "draw:image[@draw:mime-type='image/png']"_ostr); } -DECLARE_FODFEXPORT_TEST(testTdf113696WriterImage, "tdf113696-writerimage.odt") +CPPUNIT_TEST_FIXTURE(Test, testTdf113696WriterImage) { + loadFromFile(u"tdf113696-writerimage.odt"); + CPPUNIT_ASSERT_EQUAL(1, getShapes()); CPPUNIT_ASSERT_EQUAL(1, getPages()); + + save("OpenDocument Text Flat XML"); // Same as testTdf113696, but with a writer image instead of a draw image // (they use different code paths). - if (xmlDocUniquePtr pXmlDoc = parseExportedFile()) - { - assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" - "draw:image[@draw:mime-type='image/x-vclgraphic']"_ostr); - assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" - "draw:image[@draw:mime-type='image/png']"_ostr); - } + xmlDocUniquePtr pXmlDoc = parseExportedFile(); + assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" + "draw:image[@draw:mime-type='image/x-vclgraphic']"_ostr); + assertXPath(pXmlDoc, "/office:document/office:body/office:text/text:p/draw:frame/" + "draw:image[@draw:mime-type='image/png']"_ostr); } DECLARE_FODFEXPORT_TEST(testSvgImageRoundtrip, "SvgImageTest.fodt") diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx index bd87666a19eb..3a715c8434a7 100644 --- a/sw/qa/inc/swmodeltestbase.hxx +++ b/sw/qa/inc/swmodeltestbase.hxx @@ -258,13 +258,6 @@ protected: int getShapes() const; /** - * Returns an xml stream of an exported file. - * To be used when the exporter doesn't create zip archives, but single files - * (like Flat ODF Export) - */ - xmlDocUniquePtr parseExportedFile(); - - /** * Creates a new document to be used with the internal sw/ API. * * Examples: diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx index f84b3ef15b05..de3c815a7157 100644 --- a/sw/qa/unit/swmodeltestbase.cxx +++ b/sw/qa/unit/swmodeltestbase.cxx @@ -493,12 +493,6 @@ int SwModelTestBase::getShapes() const return xDraws->getCount(); } -xmlDocUniquePtr SwModelTestBase::parseExportedFile() -{ - auto stream(SvFileStream(maTempFile.GetURL(), StreamMode::READ | StreamMode::TEMPORARY)); - return parseXmlStream(&stream); -} - void SwModelTestBase::createSwDoc(const char* pName, const char* pPassword) { if (!pName) diff --git a/test/source/unoapixml_test.cxx b/test/source/unoapixml_test.cxx index f604634efd6a..bf0f830a7355 100644 --- a/test/source/unoapixml_test.cxx +++ b/test/source/unoapixml_test.cxx @@ -33,4 +33,10 @@ xmlDocUniquePtr UnoApiXmlTest::parseExport(OUString const& rStreamName) return pXmlDoc; } +xmlDocUniquePtr UnoApiXmlTest::parseExportedFile() +{ + auto stream(SvFileStream(maTempFile.GetURL(), StreamMode::READ | StreamMode::TEMPORARY)); + return parseXmlStream(&stream); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |