filter/qa/unit/svg.cxx | 11 +--- include/test/unoapi_test.hxx | 6 +- sc/qa/unit/subsequent_export_test2.cxx | 2 sw/qa/core/text/itrform2.cxx | 7 +- sw/qa/extras/htmlexport/htmlexport.cxx | 15 +---- sw/qa/extras/htmlexport/htmlexport2.cxx | 85 ++++++++++++++------------------ sw/qa/unit/swmodeltestbase.cxx | 2 test/source/unoapi_test.cxx | 22 +++----- vcl/qa/cppunit/pdfexport/pdfexport.cxx | 3 - vcl/qa/cppunit/pdfexport/pdfexport2.cxx | 36 ++++--------- 10 files changed, 75 insertions(+), 114 deletions(-)
New commits: commit d2c12c44fe15bd42906b953a54020f1a04c1d4bb Author: Xisco Fauli <[email protected]> AuthorDate: Tue Feb 3 10:14:47 2026 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Tue Feb 3 16:49:32 2026 +0100 UnoApiTest: merge save and saveWithParams into one it allows to simplify the code a bit since the TestFilter is passed as the first parameter. In preparation for a follow-up commit Change-Id: I316c88e1583dc7d9b04876883b971bdfa54e8967 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198588 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/filter/qa/unit/svg.cxx b/filter/qa/unit/svg.cxx index 2654cb6509a7..99417f95296c 100644 --- a/filter/qa/unit/svg.cxx +++ b/filter/qa/unit/svg.cxx @@ -58,10 +58,7 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testPreserveJpg) dispatchCommand(mxComponent, u".uno:JumpToNextFrame"_ustr, {}); // Export the selection to SVG. - saveWithParams({ - comphelper::makePropertyValue(u"FilterName"_ustr, u"writer_svg_Export"_ustr), - comphelper::makePropertyValue(u"SelectionOnly"_ustr, true), - }); + save(TestFilter::SVG_WRITER, { comphelper::makePropertyValue(u"SelectionOnly"_ustr, true) }); // Make sure that the original JPG data is reused and we don't perform a PNG re-compress. xmlDocUniquePtr pXmlDoc = parseExportedFile(); @@ -402,10 +399,8 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testTdf168054_export_two_pages_to_svg_using_ loadFromFile(u"tdf168054.odg"); // Emulate --convert-to svg:"draw_svg_Export" - saveWithParams({ - comphelper::makePropertyValue(u"FilterName"_ustr, u"draw_svg_Export"_ustr), - comphelper::makePropertyValue(u"ConversionRequestOrigin"_ustr, u"CommandLine"_ustr), - }); + save(TestFilter::SVG_DRAW, + { comphelper::makePropertyValue(u"ConversionRequestOrigin"_ustr, u"CommandLine"_ustr) }); xmlDocUniquePtr pXmlDoc = parseExportedFile(); CPPUNIT_ASSERT(pXmlDoc); diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx index 32719a2af52a..ba7584d7cee1 100644 --- a/include/test/unoapi_test.hxx +++ b/include/test/unoapi_test.hxx @@ -57,6 +57,7 @@ enum class TestFilter RTF, SVG_DRAW, SVG_IMPRESS, + SVG_WRITER, TEXT, TEXT_ENCODED, XHTML_CALC, @@ -102,6 +103,7 @@ const std::unordered_map<TestFilter, OUString> TestFilterNames{ { TestFilter::RTF, u"Rich Text Format"_ustr }, { TestFilter::SVG_DRAW, u"draw_svg_Export"_ustr }, { TestFilter::SVG_IMPRESS, u"impress_svg_Export"_ustr }, + { TestFilter::SVG_WRITER, u"writer_svg_Export"_ustr }, { TestFilter::TEXT, u"Text"_ustr }, { TestFilter::TEXT_ENCODED, u"Text (encoded)"_ustr }, { TestFilter::XHTML_CALC, u"XHTML Calc File"_ustr }, @@ -134,8 +136,8 @@ public: css::uno::Any executeMacro(const OUString& rScriptURL, const css::uno::Sequence<css::uno::Any>& rParams = {}); - void save(TestFilter eFilter, const char* pPassword = nullptr); - void saveWithParams(const css::uno::Sequence<css::beans::PropertyValue>& rParams); + void save(TestFilter eFilter, const css::uno::Sequence<css::beans::PropertyValue>& rParams = {}, + const char* pPassword = nullptr); void saveAndReload(TestFilter eFilter, const char* pPassword = nullptr); std::unique_ptr<vcl::pdf::PDFiumDocument> parsePDFExport(const OString& rPassword = OString()); diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 91fc5214a534..1200ea4d42d4 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -893,7 +893,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testOpenDocumentAsReadOnly) ScDocShell* pDocSh = getScDocShell(); CPPUNIT_ASSERT(pDocSh->IsSecurityOptOpenReadOnly()); - saveWithParams(uno::Sequence<beans::PropertyValue>()); + save(TestFilter::XLSX); loadWithParams(maTempFile.GetURL(), aParams); pDocSh = getScDocShell(); diff --git a/sw/qa/core/text/itrform2.cxx b/sw/qa/core/text/itrform2.cxx index 6a02317ad084..1fc9bc8c31a1 100644 --- a/sw/qa/core/text/itrform2.cxx +++ b/sw/qa/core/text/itrform2.cxx @@ -348,10 +348,9 @@ CPPUNIT_TEST_FIXTURE(Test, testContentControlPDFComments) comphelper::makePropertyValue(u"ExportNotes"_ustr, false), comphelper::makePropertyValue(u"ExportNotesInMargin"_ustr, true), }; - saveWithParams({ - comphelper::makePropertyValue(u"FilterName"_ustr, u"writer_pdf_Export"_ustr), - comphelper::makePropertyValue(u"FilterData"_ustr, aFilterData), - }); + save(TestFilter::PDF_WRITER, { + comphelper::makePropertyValue(u"FilterData"_ustr, aFilterData), + }); // Then make sure the only widget for the content control has a correct position: std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport(); diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index c32cfb0ad25c..c41c1eb5324f 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -565,11 +565,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIfPngImg) ImportFromReqif(createFileURL(u"reqif-png-img.xhtml")); verify(/*bExported=*/false); uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"ExportImagesAsOLE"_ustr, true), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); ImportFromReqif(maTempFile.GetURL()); verify(/*bExported=*/true); } @@ -800,11 +799,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testTransparentImageReqIf) { createSwDoc("transparent-image.odt"); uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"ExportImagesAsOLE"_ustr, true), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); xmlDocUniquePtr pDoc = WrapReqifFromTempFile(); OUString aSource = getXPath( @@ -935,11 +933,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testRTFOLEMimeType) // Export it. uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"RTFOLEMimeType"_ustr, aType), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); xmlDocUniquePtr pDoc = WrapReqifFromTempFile(); // Without the accompanying fix in place, this test would have failed with: @@ -1114,11 +1111,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifOle1PaintBitmapFormat) // When exporting to reqif-xhtml with ExportImagesAsOLE enabled: uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"ExportImagesAsOLE"_ustr, true), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); // Then make sure the resulting bitmap is 24bpp: OUString aRtfUrl = GetOlePath(); @@ -1455,11 +1451,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifImageToOle) // When exporting to XHTML: uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"ExportImagesAsOLE"_ustr, true), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); // Then make sure we export that PNG as WMF in ReqIF mode: OUString aRtfUrl = GetOlePath(); diff --git a/sw/qa/extras/htmlexport/htmlexport2.cxx b/sw/qa/extras/htmlexport/htmlexport2.cxx index 98e750fce375..72dd217512c4 100644 --- a/sw/qa/extras/htmlexport/htmlexport2.cxx +++ b/sw/qa/extras/htmlexport/htmlexport2.cxx @@ -48,11 +48,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifEmbedPNGShapeAsOLE) // When exporting to XHTML: uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"ExportImagesAsOLE"_ustr, true), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); // Then make sure the PNG is embedded with an RTF wrapper: xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile(); @@ -166,11 +165,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifEmbedShapeAsPNGCustomDPI) // When exporting to XHTML: uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"ShapeDPI"_ustr, nDPI), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); // Then make sure the shape is embedded as a PNG: xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile(); @@ -207,11 +205,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifOleBmpTransparent) // When exporting to reqif with ExportImagesAsOLE=true: uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"ExportImagesAsOLE"_ustr, true), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); // Then make sure the transparent pixel turns into white: SvMemoryStream aOle1; @@ -410,11 +407,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testLeadingTab) // When exporting to HTML, using LeadingTabWidth=2: uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"LeadingTabWidth"_ustr, static_cast<sal_Int32>(2)), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); // Then make sure that leading tabs are replaced with 2 nbsps: xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile(); @@ -438,10 +434,9 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testLeadingTabHTML) // When exporting to plain HTML, using LeadingTabWidth=2: uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"LeadingTabWidth"_ustr, static_cast<sal_Int32>(2)), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); // Then make sure that leading tabs are replaced with 2 nbsps: htmlDocUniquePtr pHtmlDoc = parseHtml(maTempFile); @@ -820,12 +815,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testSingleOleExport) // Store only the selection css::uno::Sequence<css::beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"RTFOLEMimeType"_ustr, u"text/rtf"_ustr), comphelper::makePropertyValue(u"SelectionOnly"_ustr, true), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile(); @@ -967,10 +961,9 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_PreserveSpaces) pWrtShell->Insert(paraText); // When exporting to plain HTML, using PreserveSpaces: - saveWithParams({ - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), - comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true), - }); + save(TestFilter::HTML_WRITER, { + comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true), + }); // Then make sure that "white-space: pre-wrap" is written into the paragraph's style: htmlDocUniquePtr pHtmlDoc = parseHtml(maTempFile); @@ -996,11 +989,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_PreserveSpaces) pWrtShell->Insert(paraText); // When exporting to ReqIF, using PreserveSpaces: - saveWithParams({ - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), - comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), - comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true), - }); + save(TestFilter::HTML_WRITER, + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true), + }); // Then make sure that xml:space="preserve" attribute exists in the paragraph element: xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile(); @@ -1043,10 +1036,9 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_NoPreserveSpaces) createSwDoc("test_no_space_preserve.fodt"); // Export to plain HTML, using PreserveSpaces: - saveWithParams({ - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), - comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true), - }); + save(TestFilter::HTML_WRITER, { + comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true), + }); htmlDocUniquePtr pHtmlDoc = parseHtml(maTempFile); CPPUNIT_ASSERT(pHtmlDoc); @@ -1102,11 +1094,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_NoPreserveSpaces) createSwDoc("test_no_space_preserve.fodt"); // Export to ReqIF, using PreserveSpaces: - saveWithParams({ - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), - comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), - comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true), - }); + save(TestFilter::HTML_WRITER, + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + comphelper::makePropertyValue(u"PreserveSpaces"_ustr, true), + }); xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile(); @@ -1166,11 +1158,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_ExportFormulasAsPDF) // When exporting to reqif with ExportFormulasAsPDF=true: uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"ExportFormulasAsPDF"_ustr, true), }; - saveWithParams(aStoreProperties); + save(TestFilter::HTML_WRITER, aStoreProperties); // Make sure that the formula is exported as PDF: xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile(); @@ -1332,12 +1323,12 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_exportAbsoluteURLs_ownRelati createSwDoc("URLs.odt"); // Export to ReqIF, using absolute URLs - saveWithParams({ - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), - comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), - comphelper::makePropertyValue(u"ExportImagesAsOLE"_ustr, true), - comphelper::makePropertyValue(u"RelativeOwnObjectURL"_ustr, true), - }); + save(TestFilter::HTML_WRITER, + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + comphelper::makePropertyValue(u"ExportImagesAsOLE"_ustr, true), + comphelper::makePropertyValue(u"RelativeOwnObjectURL"_ustr, true), + }); xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile(); // HTTP URL: must be absolute @@ -1386,11 +1377,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_exportRelativeURLs) createSwDoc("URLs.odt"); // Export to ReqIF, using relative URLs (the default) - saveWithParams({ - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), - comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), - comphelper::makePropertyValue(u"ExportImagesAsOLE"_ustr, true), - }); + save(TestFilter::HTML_WRITER, + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + comphelper::makePropertyValue(u"ExportImagesAsOLE"_ustr, true), + }); xmlDocUniquePtr pXmlDoc = WrapReqifFromTempFile(); // HTTP URL: must be absolute @@ -1443,10 +1434,10 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testHTML_exportAbsoluteURLs_ownRelativ createSwDoc("URLs.odt"); // Export to HTML, using absolute URLs - saveWithParams({ - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), - comphelper::makePropertyValue(u"RelativeOwnObjectURL"_ustr, true), - }); + save(TestFilter::HTML_WRITER, + { + comphelper::makePropertyValue(u"RelativeOwnObjectURL"_ustr, true), + }); htmlDocUniquePtr pHtmlDoc = parseHtml(maTempFile); // HTTP URL: must be absolute diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx index 7a1c0d5609ad..e6911497644c 100644 --- a/sw/qa/unit/swmodeltestbase.cxx +++ b/sw/qa/unit/swmodeltestbase.cxx @@ -386,7 +386,7 @@ void SwModelTestBase::loadURL(OUString const& rURL, const char* pPassword) void SwModelTestBase::saveAndReload(TestFilter eFilter, const char* pPassword) { - save(eFilter, pPassword); + save(eFilter, /*rParams*/ {}, pPassword); loadURL(maTempFile.GetURL(), pPassword); } diff --git a/test/source/unoapi_test.cxx b/test/source/unoapi_test.cxx index 57c8b11cc0c2..be6028aeae66 100644 --- a/test/source/unoapi_test.cxx +++ b/test/source/unoapi_test.cxx @@ -150,11 +150,15 @@ uno::Any UnoApiTest::executeMacro(const OUString& rScriptURL, return aRet; } -void UnoApiTest::save(TestFilter eFilter, const char* pPassword) +void UnoApiTest::save(TestFilter eFilter, const uno::Sequence<beans::PropertyValue>& rParams, + const char* pPassword) { OUString aFilter(TestFilterNames.at(eFilter)); comphelper::SequenceAsHashMap aMediaDescriptor; aMediaDescriptor[u"FilterName"_ustr] <<= aFilter; + + if (rParams.hasElements()) + aMediaDescriptor.update(rParams); if (!maFilterOptions.isEmpty()) aMediaDescriptor[u"FilterOptions"_ustr] <<= maFilterOptions; @@ -179,26 +183,16 @@ void UnoApiTest::save(TestFilter eFilter, const char* pPassword) skipValidation(); } - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); -} - -void UnoApiTest::saveWithParams(const uno::Sequence<beans::PropertyValue>& rParams) -{ css::uno::Reference<frame::XStorable> xStorable(mxComponent, css::uno::UNO_QUERY_THROW); - xStorable->storeToURL(maTempFile.GetURL(), rParams); + xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); if (!mbSkipValidation) - { - ::comphelper::SequenceAsHashMap aParamsHash(rParams); - OUString aFilterName; - aParamsHash.getValue(u"FilterName"_ustr) >>= aFilterName; - validate(maTempFile.GetFileName(), aFilterName); - } + validate(maTempFile.GetFileName(), aFilter); } void UnoApiTest::saveAndReload(TestFilter eFilter, const char* pPassword) { - save(eFilter, pPassword); + save(eFilter, /*rParams*/ {}, pPassword); loadFromURL(maTempFile.GetURL(), pPassword); } diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 7711277424ff..3641f182e72d 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -69,8 +69,7 @@ void PdfExportTest::saveAsPDF(std::u16string_view rFile) { // Import the bugdoc and export as PDF. loadFromFile(rFile); - aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr; - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER, aMediaDescriptor.getAsConstPropertyValueList()); } void PdfExportTest::load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument) diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx index c9eb9c26f788..122a0a68cf99 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx @@ -76,8 +76,7 @@ void PdfExportTest2::saveAsPDF(std::u16string_view rFile) { // Import the bugdoc and export as PDF. loadFromFile(rFile); - aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr; - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER, aMediaDescriptor.getAsConstPropertyValueList()); } void PdfExportTest2::load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument) @@ -707,8 +706,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testPdfImageResourceInlineXObjectRef) xText->insertTextContent(xCursor->getStart(), xTextContent, /*bAbsorb=*/false); // Save as PDF. - aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr; - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER); // Parse the export result. std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport(); @@ -757,8 +755,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testDefaultVersion) loadFromURL(u"private:factory/swriter"_ustr); // Save as PDF. - aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr; - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER); // Parse the export result. std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport(); @@ -774,9 +771,8 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testVersion15) // Save as PDF. uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( { { "SelectPdfVersion", uno::Any(static_cast<sal_Int32>(15)) } })); - aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr; aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER, aMediaDescriptor.getAsConstPropertyValueList()); // Parse the export result. std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport(); @@ -790,12 +786,10 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testVersion20) mxComponent = loadFromDesktop("private:factory/swriter"); // Save as PDF. - uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); uno::Sequence<beans::PropertyValue> aFilterData = comphelper::InitPropertySequence( { { "SelectPdfVersion", uno::Any(static_cast<sal_Int32>(20)) } }); - aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export"); aMediaDescriptor["FilterData"] <<= aFilterData; - xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER, aMediaDescriptor.getAsConstPropertyValueList()); // Parse the export result. std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport(); @@ -1618,7 +1612,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf152231) CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf152235) { - aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr; // Enable PDF/UA uno::Sequence<beans::PropertyValue> aFilterData(comphelper::InitPropertySequence( { { "PDFUACompliance", uno::Any(true) }, @@ -1628,7 +1621,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf152235) { "SelectPdfVersion", uno::Any(sal_Int32(17)) } })); aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; loadFromURL(u"private:factory/swriter"_ustr); - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER, aMediaDescriptor.getAsConstPropertyValueList()); vcl::filter::PDFDocument aDocument; SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ); @@ -3992,13 +3985,11 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf142129) // update linked section dispatchCommand(mxComponent, u".uno:UpdateAllLinks"_ustr, {}); - aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr; - // Enable Outlines export uno::Sequence<beans::PropertyValue> aFilterData( comphelper::InitPropertySequence({ { "ExportBookmarks", uno::Any(true) } })); aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER, aMediaDescriptor.getAsConstPropertyValueList()); // Parse the export result. vcl::filter::PDFDocument aDocument; @@ -4089,8 +4080,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testPdfImageRotate180) xText->insertTextContent(xCursor->getStart(), xTextContent, /*bAbsorb=*/false); // Save as PDF. - aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr; - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER); // Parse the export result. std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport(); @@ -4334,8 +4324,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testURIs) xCursorProps->setPropertyValue(u"HyperLinkName"_ustr, uno::Any(u"Testname"_ustr)); // Save as PDF. - aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr; - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER, aMediaDescriptor.getAsConstPropertyValueList()); // Use the filter rather than the pdfium route, as per the tdf105093 test, it's // easier to parse the annotations @@ -4415,13 +4404,12 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testPdfImageEncryption) xText->insertTextContent(xCursor->getStart(), xTextContent, /*bAbsorb=*/false); // When saving as encrypted PDF: - aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr; uno::Sequence<beans::PropertyValue> aFilterData = { comphelper::makePropertyValue(u"EncryptFile"_ustr, true), comphelper::makePropertyValue(u"DocumentOpenPassword"_ustr, u"secret"_ustr), }; aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData; - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER, aMediaDescriptor.getAsConstPropertyValueList()); // Then make sure that the image is not lost: std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport("secret"_ostr); @@ -4971,8 +4959,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf113866) rDocAccess.setPrintData(aDocPrintData); // Export to pdf - aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr; - saveWithParams(aMediaDescriptor.getAsConstPropertyValueList()); + save(TestFilter::PDF_WRITER); // Parse the export result with pdfium. std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport(); @@ -6175,7 +6162,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testPDFAttachmentsWithEncryptedFile) // Encrypt the document and use the hybrid mode. // The original ODF document will be saved to the PDF as an attachment. - aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export"); uno::Sequence<beans::PropertyValue> aFilterData = { comphelper::makePropertyValue("IsAddStream", true), comphelper::makePropertyValue("EncryptFile", true),
