filter/qa/unit/svg.cxx | 5 - 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/extras/htmlexport/htmlmodeltestbase.hxx | 8 -- sw/qa/unit/swmodeltestbase.cxx | 2 test/source/unoapi_test.cxx | 29 ++------ vcl/qa/cppunit/pdfexport/pdfexport.cxx | 3 vcl/qa/cppunit/pdfexport/pdfexport2.cxx | 36 +++-------- 11 files changed, 73 insertions(+), 125 deletions(-)
New commits: commit f7420bba64053d95ac6e2df6d7395d1e2bc53009 Author: Xisco Fauli <[email protected]> AuthorDate: Tue Feb 3 10:14:47 2026 +0100 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Tue Mar 10 02:09:25 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]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201179 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/filter/qa/unit/svg.cxx b/filter/qa/unit/svg.cxx index 17637d10de3c..fefe3ed8f1dc 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(); diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx index 140d8ead3fe7..92694702bc9d 100644 --- a/include/test/unoapi_test.hxx +++ b/include/test/unoapi_test.hxx @@ -65,6 +65,7 @@ enum class TestFilter RTF, SVG_DRAW, SVG_IMPRESS, + SVG_WRITER, TEXT, TEXT_ENCODED, XHTML_CALC, @@ -111,6 +112,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 }, @@ -143,8 +145,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 9c6400375cd9..fecfddf31a52 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -880,7 +880,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 10931b0dfa41..61f9cf3d5277 100644 --- a/sw/qa/core/text/itrform2.cxx +++ b/sw/qa/core/text/itrform2.cxx @@ -342,10 +342,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 4dac93fc04d2..3e39aef600f0 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 7ef8d436c9ac..c0d160488c8d 100644 --- a/sw/qa/extras/htmlexport/htmlexport2.cxx +++ b/sw/qa/extras/htmlexport/htmlexport2.cxx @@ -49,11 +49,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(); @@ -167,11 +166,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(); @@ -208,11 +206,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; @@ -411,11 +408,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(); @@ -439,10 +435,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); @@ -821,12 +816,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(); @@ -968,10 +962,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); @@ -997,11 +990,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(); @@ -1044,10 +1037,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); @@ -1103,11 +1095,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(); @@ -1167,11 +1159,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(); @@ -1343,12 +1334,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 @@ -1397,11 +1388,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 @@ -1464,10 +1455,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/extras/htmlexport/htmlmodeltestbase.hxx b/sw/qa/extras/htmlexport/htmlmodeltestbase.hxx index 268582a490a5..27a75063df6d 100644 --- a/sw/qa/extras/htmlexport/htmlmodeltestbase.hxx +++ b/sw/qa/extras/htmlexport/htmlmodeltestbase.hxx @@ -213,13 +213,7 @@ void SwHtmlDomExportTest::ExportToReqif() save(TestFilter::HTML_WRITER); } -void SwHtmlDomExportTest::ExportToHTML() -{ - uno::Sequence<beans::PropertyValue> aStoreProperties = { - comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), - }; - saveWithParams(aStoreProperties); -} +void SwHtmlDomExportTest::ExportToHTML() { save(TestFilter::HTML_WRITER); } void SwHtmlDomExportTest::ImportFromReqif(const OUString& rUrl) { diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx index e149687a9cf1..695dfd069a5e 100644 --- a/sw/qa/unit/swmodeltestbase.cxx +++ b/sw/qa/unit/swmodeltestbase.cxx @@ -388,7 +388,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 e249c2e1a5bb..e0a1a0e11215 100644 --- a/test/source/unoapi_test.cxx +++ b/test/source/unoapi_test.cxx @@ -320,11 +320,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)); utl::MediaDescriptor aMediaDescriptor; aMediaDescriptor[u"FilterName"_ustr] <<= aFilter; + + if (rParams.hasElements()) + aMediaDescriptor.update(rParams); if (!maFilterOptions.isEmpty()) aMediaDescriptor[u"FilterOptions"_ustr] <<= maFilterOptions; @@ -349,35 +353,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; - TestFilter eFilter = TestFilter::NONE; - for (const auto & [ key, value ] : TestFilterNames) - { - if (value == aFilterName) - { - eFilter = key; - break; - } - } validate(maTempFile.GetFileName(), eFilter); - } } 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 1e22b31ae4f3..0837e4b3222a 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -61,8 +61,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 e0bc9337994e..d2359cdcba8a 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx @@ -72,8 +72,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) @@ -703,8 +702,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(); @@ -753,8 +751,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(); @@ -770,9 +767,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(); @@ -786,12 +782,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(); @@ -1614,7 +1608,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) }, @@ -1624,7 +1617,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); @@ -3988,13 +3981,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; @@ -4085,8 +4076,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(); @@ -4330,8 +4320,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 @@ -4411,13 +4400,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); @@ -4967,8 +4955,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(); @@ -6171,7 +6158,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),
