include/test/unoapi_test.hxx | 6 --- sw/qa/core/layout/flycnt.cxx | 2 - sw/qa/extras/embedded_fonts/embedded_fonts.cxx | 32 ++++++++-------- sw/qa/extras/globalfilter/globalfilter.cxx | 7 ++- sw/qa/extras/htmlexport/htmlexport.cxx | 48 ++++++++++++++++--------- sw/qa/extras/htmlexport/htmlexport2.cxx | 12 ++++-- sw/qa/extras/htmlimport/htmlimport.cxx | 44 +++++++++++++++------- sw/qa/extras/layout/layout2.cxx | 2 - sw/qa/extras/layout/layout6.cxx | 6 +-- sw/qa/extras/odfexport/odfexport.cxx | 4 +- sw/qa/extras/ooxmlexport/ooxmlencryption.cxx | 8 ++-- sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 2 - sw/qa/extras/pdf/HybridPdfTest.cxx | 3 + sw/qa/filter/html/html.cxx | 27 +++++++++----- sw/qa/filter/md/md.cxx | 24 ++++++------ sw/qa/inc/swmodeltestbase.hxx | 6 ++- sw/qa/unit/swmodeltestbase.cxx | 14 ++++--- test/source/unoapi_test.cxx | 5 -- 18 files changed, 150 insertions(+), 102 deletions(-)
New commits: commit a69b44ce920a02054cce4ee498b00ea14ef13f14 Author: Xisco Fauli <[email protected]> AuthorDate: Thu Feb 12 21:20:03 2026 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Feb 13 15:57:24 2026 +0100 UnoApiTest: drop setImportFilterOptions and just pass FilterOptions as a parameter Change-Id: I729a48caad421c98623d0500c70af8af37663b27 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199304 Reviewed-by: Xisco Fauli <[email protected]> Tested-by: Jenkins diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx index 5554cedc3daa..6d04a669e44e 100644 --- a/include/test/unoapi_test.hxx +++ b/include/test/unoapi_test.hxx @@ -161,11 +161,6 @@ public: void skipValidation() { mbSkipValidation = true; } - void setImportFilterOptions(const OUString& rFilterOptions) - { - maImportFilterOptions = rFilterOptions; - } - void setImportFilterName(TestFilter eFilterName) { meImportFilterName = eFilterName; } protected: @@ -187,7 +182,6 @@ private: bool mbSkipValidation; OUString m_aBaseString; - OUString maImportFilterOptions; TestFilter meImportFilterName; }; diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index aae2fb2bcdbe..a2b57628b615 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -744,7 +744,7 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyThenTable) uno::Sequence<beans::PropertyValue> aFilterOptions = { comphelper::makePropertyValue(u"Hidden"_ustr, true), }; - loadFromFile(u"floattable-then-table.docx", aFilterOptions); + createSwDoc("floattable-then-table.docx", aFilterOptions); // When layout is calculated during PDF export: // Then make sure that finishes without errors: diff --git a/sw/qa/extras/embedded_fonts/embedded_fonts.cxx b/sw/qa/extras/embedded_fonts/embedded_fonts.cxx index 523b060e5646..761c2a12182f 100644 --- a/sw/qa/extras/embedded_fonts/embedded_fonts.cxx +++ b/sw/qa/extras/embedded_fonts/embedded_fonts.cxx @@ -173,10 +173,10 @@ CPPUNIT_TEST_FIXTURE(Test, testOpenODTWithRestrictedEmbeddedFont) // 1. Load and do not approve the restricted font FontMappingUseListener fontMappingData; rtl::Reference xInteraction(new FontInteractionHandler(false)); - loadFromFile(u"embed-restricted-style+autostyle.odt", - { comphelper::makePropertyValue( - u"InteractionHandler"_ustr, - uno::Reference<task::XInteractionHandler>(xInteraction)) }); + createSwDoc("embed-restricted-style+autostyle.odt", + { comphelper::makePropertyValue( + u"InteractionHandler"_ustr, + uno::Reference<task::XInteractionHandler>(xInteraction)) }); // It asked exactly once, even though both styles.xml and content.xml requested the font: CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount()); @@ -207,10 +207,10 @@ CPPUNIT_TEST_FIXTURE(Test, testOpenODTWithRestrictedEmbeddedFont) // 2. Load and approve the restricted font FontMappingUseListener fontMappingData; rtl::Reference xInteraction(new FontInteractionHandler(true)); - loadFromFile(u"embed-restricted-style+autostyle.odt", - { comphelper::makePropertyValue( - u"InteractionHandler"_ustr, - uno::Reference<task::XInteractionHandler>(xInteraction)) }); + createSwDoc("embed-restricted-style+autostyle.odt", + { comphelper::makePropertyValue( + u"InteractionHandler"_ustr, + uno::Reference<task::XInteractionHandler>(xInteraction)) }); // It asked exactly once, even though both styles.xml and content.xml requested the font: CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount()); @@ -276,10 +276,10 @@ CPPUNIT_TEST_FIXTURE(Test, testOpenDOCXWithRestrictedEmbeddedFont) // unrestricted one must load. FontMappingUseListener fontMappingData; rtl::Reference xInteraction(new FontInteractionHandler(false)); - loadFromFile(u"embed-restricted+unrestricted.docx", - { comphelper::makePropertyValue( - u"InteractionHandler"_ustr, - uno::Reference<task::XInteractionHandler>(xInteraction)) }); + createSwDoc("embed-restricted+unrestricted.docx", + { comphelper::makePropertyValue( + u"InteractionHandler"_ustr, + uno::Reference<task::XInteractionHandler>(xInteraction)) }); CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount()); // It requested only the expected font (no requests for 'Unsteady Oversteer') @@ -312,10 +312,10 @@ CPPUNIT_TEST_FIXTURE(Test, testOpenDOCXWithRestrictedEmbeddedFont) // mode. FontMappingUseListener fontMappingData; rtl::Reference xInteraction(new FontInteractionHandler(true)); - loadFromFile(u"embed-restricted+unrestricted.docx", - { comphelper::makePropertyValue( - u"InteractionHandler"_ustr, - uno::Reference<task::XInteractionHandler>(xInteraction)) }); + createSwDoc("embed-restricted+unrestricted.docx", + { comphelper::makePropertyValue( + u"InteractionHandler"_ustr, + uno::Reference<task::XInteractionHandler>(xInteraction)) }); CPPUNIT_ASSERT_EQUAL(1, xInteraction->getRequestCount()); // It requested the expected font diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 85532ee6de96..1023e225ff61 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -25,6 +25,7 @@ #include <vcl/vectorgraphicdata.hxx> #include <sfx2/linkmgr.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/scopeguard.hxx> #include <comphelper/sequenceashashmap.hxx> #include <unotxdoc.hxx> @@ -799,8 +800,10 @@ void Test::testSkipImages() bool bSkipImages = !rFilterNamePair.second.isEmpty(); OString sFailedMessage = OString::Concat("Failed on filter: ") + rFilterNamePair.first.toUtf8(); - setImportFilterOptions(rFilterNamePair.second); - createSwDoc(rFilterNamePair.first.toUtf8().getStr()); + createSwDoc(rFilterNamePair.first.toUtf8().getStr(), + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, rFilterNamePair.second), + }); sFailedMessage += " - " + rFilterNamePair.second.toUtf8(); // Check shapes (images, textboxes, custom shapes) diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 315884006cd6..51ac39e67f0d 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -424,9 +424,11 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testXHTML) CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfParagraph) { - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("reqif-p.xhtml"); + createSwDoc("reqif-p.xhtml", { + comphelper::makePropertyValue(u"FilterOptions"_ustr, + u"xhtmlns=reqif-xhtml"_ustr), + }); save(TestFilter::HTML_WRITER, { comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), @@ -477,9 +479,11 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfOleData) // Then this was 0 on export, as data of OLE nodes was ignored. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xObjects->getCount()); }; - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("reqif-ole-data.xhtml"); + createSwDoc("reqif-ole-data.xhtml", { + comphelper::makePropertyValue( + u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); verify(); saveAndReload( TestFilter::HTML_WRITER, @@ -531,9 +535,11 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfOleImg) getProperty<OUString>(xObject, u"Title"_ustr).trim()); }; - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("reqif-ole-img.xhtml"); + createSwDoc("reqif-ole-img.xhtml", { + comphelper::makePropertyValue( + u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); verify(); saveAndReload( TestFilter::HTML_WRITER, @@ -594,9 +600,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIfPngImg) CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfJpgImg) { - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("reqif-jpg-img.xhtml"); + createSwDoc("reqif-jpg-img.xhtml", { + comphelper::makePropertyValue( + u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); save(TestFilter::HTML_WRITER, { comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), @@ -612,9 +620,11 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfJpgImg) CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfTable) { - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("reqif-table.xhtml"); + createSwDoc("reqif-table.xhtml", { + comphelper::makePropertyValue(u"FilterOptions"_ustr, + u"xhtmlns=reqif-xhtml"_ustr), + }); save(TestFilter::HTML_WRITER, { comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), @@ -699,9 +709,11 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testXHTMLUseCSS) CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfList) { - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("reqif-list.xhtml"); + createSwDoc("reqif-list.xhtml", { + comphelper::makePropertyValue(u"FilterOptions"_ustr, + u"xhtmlns=reqif-xhtml"_ustr), + }); save(TestFilter::HTML_WRITER, { comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), @@ -745,9 +757,11 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfOle2) // exception of type com.sun.star.io.IOException was thrown. }; - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("reqif-ole2.xhtml"); + createSwDoc("reqif-ole2.xhtml", { + comphelper::makePropertyValue(u"FilterOptions"_ustr, + u"xhtmlns=reqif-xhtml"_ustr), + }); verify(); saveAndReload( TestFilter::HTML_WRITER, @@ -792,9 +806,11 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfOle2Odg) CPPUNIT_ASSERT(xObject.is()); CPPUNIT_ASSERT(xObject->supportsService(u"com.sun.star.drawing.DrawingDocument"_ustr)); }; - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("reqif-ole-odg.xhtml"); + createSwDoc("reqif-ole-odg.xhtml", { + comphelper::makePropertyValue( + u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); verify(); saveAndReload( TestFilter::HTML_WRITER, diff --git a/sw/qa/extras/htmlexport/htmlexport2.cxx b/sw/qa/extras/htmlexport/htmlexport2.cxx index 8f0cc3ceb735..b1bea2f058f3 100644 --- a/sw/qa/extras/htmlexport/htmlexport2.cxx +++ b/sw/qa/extras/htmlexport/htmlexport2.cxx @@ -1007,9 +1007,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_PreserveSpaces) // Test import - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - loadFromURL(maTempFile.GetURL()); + loadFromURL(maTempFile.GetURL(), { + comphelper::makePropertyValue(u"FilterOptions"_ustr, + u"xhtmlns=reqif-xhtml"_ustr), + }); CPPUNIT_ASSERT_EQUAL(paraText, getParagraph(1)->getString()); } @@ -1136,9 +1138,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIF_NoPreserveSpaces) // Test import - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - loadFromURL(maTempFile.GetURL()); + loadFromURL(maTempFile.GetURL(), { + comphelper::makePropertyValue(u"FilterOptions"_ustr, + u"xhtmlns=reqif-xhtml"_ustr), + }); CPPUNIT_ASSERT_EQUAL(u"No special spaces"_ustr, getParagraph(1)->getString()); CPPUNIT_ASSERT_EQUAL(u" Leading space"_ustr, getParagraph(2)->getString()); diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 12534e8a9e8a..c183892a349b 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -313,9 +313,11 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testOutlineLevel) CPPUNIT_TEST_FIXTURE(HtmlImportTest, testReqIfBr) { - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("reqif-br.xhtml"); + createSwDoc("reqif-br.xhtml", + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); // <reqif-xhtml:br/> was not recognized as a line break from a ReqIf file. CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("aaa bbb")); } @@ -342,9 +344,11 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf80194_subscript) CPPUNIT_TEST_FIXTURE(HtmlImportTest, testReqIfTable) { - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("reqif-table.xhtml"); + createSwDoc("reqif-table.xhtml", + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); // to see this: soffice --infilter="HTML (StarWriter):xhtmlns=reqif-xhtml" sw/qa/extras/htmlimport/data/reqif-table.xhtml // Load a table with xhtmlns=reqif-xhtml filter param. uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); @@ -467,9 +471,11 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf118579) CPPUNIT_TEST_FIXTURE(HtmlImportTest, testReqIfPageStyle) { - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("reqif-page-style.xhtml"); + createSwDoc("reqif-page-style.xhtml", + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); // Without the accompanying fix in place, this test would have failed with // 'Expected: Standard, Actual : HTML'. CPPUNIT_ASSERT_EQUAL(u"Standard"_ustr, @@ -491,7 +497,7 @@ CPPUNIT_TEST_FIXTURE(SwHtmlOptionsImportTest, testAllowedRTFOLEMimeTypes) comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"AllowedRTFOLEMimeTypes"_ustr, aTypes), }; - loadFromFile(u"allowed-rtf-ole-mime-types.xhtml", aLoadProperties); + createSwDoc("allowed-rtf-ole-mime-types.xhtml", aLoadProperties); uno::Reference<text::XTextEmbeddedObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xObjects(xSupplier->getEmbeddedObjects(), uno::UNO_QUERY); @@ -526,9 +532,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlOptionsImportTest, testOleImg) { // Given an XHTML with an <object> (containing GIF) and an inner <object> (containing PNG, to be // ignored): - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("ole-img.xhtml"); + createSwDoc("ole-img.xhtml", + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); // Then make sure the result is a single Writer image: uno::Reference<text::XTextGraphicObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY); @@ -545,9 +553,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlOptionsImportTest, testOleImgSvg) { // Given an XHTML with an <object> (containing SVG) and an inner <object> (containing PNG, to be // ignored): - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("ole-img-svg.xhtml"); + createSwDoc("ole-img-svg.xhtml", + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); // Then make sure the result is a single Writer image: uno::Reference<text::XTextGraphicObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY); @@ -582,9 +592,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlOptionsImportTest, testOleData) { // Given an XHTML with an <object> (containing non-image, non-OLE2 data) and an inner <object> // (containing PNG): - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("ole-data.xhtml"); + createSwDoc("ole-data.xhtml", + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); // Then make sure the result is a single clickable Writer image: uno::Reference<text::XTextGraphicObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY); @@ -603,9 +615,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlOptionsImportTest, testOleData) CPPUNIT_TEST_FIXTURE(SwHtmlOptionsImportTest, testOleData2) { // Given an XHTML with 2 objects: the first has a link, the second does not have: - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("ole-data2.xhtml"); + createSwDoc("ole-data2.xhtml", + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); // Then make sure that the second image doesn't have a link set: uno::Reference<text::XTextGraphicObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY); diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index b4fa380c32e1..2e2ce2c2376a 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -1521,7 +1521,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTableCellInvalidate) }; // inline the loading because currently properties can't be passed... - loadFromFile(u"table_cell_overlap.fodt", comphelper::containerToSequence(aFilterOptions)); + createSwDoc("table_cell_overlap.fodt", comphelper::containerToSequence(aFilterOptions)); save(TestFilter::PDF_WRITER); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); diff --git a/sw/qa/extras/layout/layout6.cxx b/sw/qa/extras/layout/layout6.cxx index 26c7044f9674..30c935a59276 100644 --- a/sw/qa/extras/layout/layout6.cxx +++ b/sw/qa/extras/layout/layout6.cxx @@ -683,7 +683,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter6, testTdf122607_regression) }; // inline the loading because currently properties can't be passed... - loadFromFile(u"tdf122607_leerzeile.odt", comphelper::containerToSequence(aFilterOptions)); + createSwDoc("tdf122607_leerzeile.odt", comphelper::containerToSequence(aFilterOptions)); save(TestFilter::PDF_WRITER); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); @@ -710,7 +710,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter6, TestTdf150616) }; // inline the loading because currently properties can't be passed... - loadFromFile(u"in_056132_mod.odt", comphelper::containerToSequence(aFilterOptions)); + createSwDoc("in_056132_mod.odt", comphelper::containerToSequence(aFilterOptions)); save(TestFilter::PDF_WRITER); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); @@ -1519,7 +1519,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter6, testTdf156724) }; // inline the loading because currently properties can't be passed... - loadFromFile(u"fdo56797-2-min.odt", comphelper::containerToSequence(aFilterOptions)); + createSwDoc("fdo56797-2-min.odt", comphelper::containerToSequence(aFilterOptions)); save(TestFilter::PDF_WRITER); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 03c31089bd95..153b1a56197e 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -485,7 +485,7 @@ CPPUNIT_TEST_FIXTURE(Test, testFramebackgrounds) CPPUNIT_TEST_FIXTURE(Test, testSHA1Correct) { // tdf#114939 this has both an affected password as well as content.xml const char* const sPass = "1012345678901234567890123456789012345678901234567890"; - createSwDoc("sha1_correct.odt", sPass); + createSwDoc("sha1_correct.odt", /*rParams*/ {}, sPass); CPPUNIT_ASSERT_EQUAL(1, getPages()); getParagraph(1, u"012"_ustr); @@ -499,7 +499,7 @@ CPPUNIT_TEST_FIXTURE(Test, testSHA1Correct) CPPUNIT_TEST_FIXTURE(Test, testSHA1Wrong) { // tdf#114939 this has both an affected password as well as content.xml const char* const sPass = "1012345678901234567890123456789012345678901234567890"; - createSwDoc("sha1_wrong.odt", sPass); + createSwDoc("sha1_wrong.odt", /*rParams*/ {}, sPass); CPPUNIT_ASSERT_EQUAL(1, getPages()); getParagraph(1, u"012"_ustr); diff --git a/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx b/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx index f288d9e56193..9fd5c492b4ad 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx @@ -22,7 +22,7 @@ public: CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2007) { const char* const sPass = "abc"; - createSwDoc("Encrypted_MSO2007_abc.docx", sPass); + createSwDoc("Encrypted_MSO2007_abc.docx", /*rParams*/ {}, sPass); // Standard encryption format, AES 128, SHA1 uno::Reference<text::XTextRange> xParagraph(getParagraph(1)); CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, getParagraph(1)->getString()); @@ -33,7 +33,7 @@ CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2007) CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2010) { const char* const sPass = "abc"; - createSwDoc("Encrypted_MSO2010_abc.docx", sPass); + createSwDoc("Encrypted_MSO2010_abc.docx", /*rParams*/ {}, sPass); // Agile encryption format, AES 128, CBC, SHA1 CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, getParagraph(1)->getString()); saveAndReload(TestFilter::DOCX, /*rParams*/ {}, sPass); @@ -43,7 +43,7 @@ CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2010) CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2013) { const char* const sPass = "abc"; - createSwDoc("Encrypted_MSO2013_abc.docx", sPass); + createSwDoc("Encrypted_MSO2013_abc.docx", /*rParams*/ {}, sPass); // Agile encryption format, AES 256, CBC, SHA512 uno::Reference<text::XTextRange> xParagraph(getParagraph(1)); CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, getParagraph(1)->getString()); @@ -54,7 +54,7 @@ CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2013) CPPUNIT_TEST_FIXTURE(Test, testPasswordLOStandard) { const char* const sPass = "abc"; - createSwDoc("Encrypted_LO_Standard_abc.docx", sPass); + createSwDoc("Encrypted_LO_Standard_abc.docx", /*rParams*/ {}, sPass); // Standard encryption format, AES 128, SHA1 uno::Reference<text::XTextRange> xParagraph(getParagraph(1)); CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, getParagraph(1)->getString()); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index c98890de9841..1e3ee19f47ae 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -826,7 +826,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTableStyleConfNested) CPPUNIT_TEST_FIXTURE(Test, testTdf133771) { // Create the doc model. - createSwDoc("tdf133771.odt", /*pPassword*/ "test"); + createSwDoc("tdf133771.odt", /*rParams*/ {}, /*pPassword*/ "test"); CPPUNIT_ASSERT_EQUAL(u"Password Protected"_ustr, getParagraph(1)->getString()); diff --git a/sw/qa/extras/pdf/HybridPdfTest.cxx b/sw/qa/extras/pdf/HybridPdfTest.cxx index e6b102567a5a..33daadd00aaf 100644 --- a/sw/qa/extras/pdf/HybridPdfTest.cxx +++ b/sw/qa/extras/pdf/HybridPdfTest.cxx @@ -82,7 +82,8 @@ void HybridPdfTest::testHybridWithAttachedFileAndPass() // The ODT document is embedded using an attached file conforming to the PDF specs // it doesn't have the "/AdditionalStreams" // The file is encrypted - createSwDoc("Hybrid_EmbeddedFileOnlyPDF20UAPasswordpop.pdf", "pop"); + createSwDoc("Hybrid_EmbeddedFileOnlyPDF20UAPasswordpop.pdf", /*rParams*/ {}, + /*pPassword*/ "pop"); // We can access the document text in a single paragraph that spans multiple rows // This wouldn't be possible with a PDF, so the opened document has to be ODT diff --git a/sw/qa/filter/html/html.cxx b/sw/qa/filter/html/html.cxx index 0ef77459d48d..3af058c01638 100644 --- a/sw/qa/filter/html/html.cxx +++ b/sw/qa/filter/html/html.cxx @@ -47,9 +47,12 @@ public: CPPUNIT_TEST_FIXTURE(Test, testEmptyParagraph) { // Given a document with 2 paragraphs, the second is empty: - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("empty-paragraph.xhtml"); + createSwDoc( + "empty-paragraph.xhtml", + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); // Then make sure that the resulting document has a 2nd empty paragraph: getParagraph(1, u"a"_ustr); @@ -62,9 +65,12 @@ CPPUNIT_TEST_FIXTURE(Test, testEmptyParagraph) CPPUNIT_TEST_FIXTURE(Test, testRelativeKeepAspect) { // Given a document with an OLE object, width set to 100%, height is not set: - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("relative-keep-aspect.xhtml"); + createSwDoc( + "relative-keep-aspect.xhtml", + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); // Then make sure that the aspect ratio of the image is kept: SwDoc* pDoc = getSwDoc(); @@ -82,9 +88,12 @@ CPPUNIT_TEST_FIXTURE(Test, testRelativeKeepAspect) CPPUNIT_TEST_FIXTURE(Test, testRelativeKeepAspectImage) { // Given a document with an image, width set to 100%, height is not set: - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("relative-keep-aspect-image.xhtml"); + createSwDoc( + "relative-keep-aspect-image.xhtml", + { + comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); // Then make sure that the aspect ratio of the image is kept: SwDoc* pDoc = getSwDoc(); @@ -229,9 +238,11 @@ CPPUNIT_TEST_FIXTURE(Test, testCenteredTableCSSExport) CPPUNIT_TEST_FIXTURE(Test, testCenteredTableCSSImport) { // Given an XHTML file with a centered (with inline CSS) table, when importing that document: - setImportFilterOptions(u"xhtmlns=reqif-xhtml"_ustr); setImportFilterName(TestFilter::HTML_WRITER); - createSwDoc("centered-table.xhtml"); + createSwDoc("centered-table.xhtml", { + comphelper::makePropertyValue( + u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), + }); // Then make sure that the table is centered: SwDoc* pDoc = getSwDoc(); diff --git a/sw/qa/filter/md/md.cxx b/sw/qa/filter/md/md.cxx index c64b16c8b9c1..a7d2dc20e906 100644 --- a/sw/qa/filter/md/md.cxx +++ b/sw/qa/filter/md/md.cxx @@ -13,6 +13,7 @@ #include <com/sun/star/style/ParagraphAdjust.hpp> +#include <comphelper/propertyvalue.hxx> #include <vcl/graphicfilter.hxx> #include <svx/xfillit0.hxx> #include <svx/xflclit.hxx> @@ -939,15 +940,16 @@ CPPUNIT_TEST_FIXTURE(Test, testEmbeddedAnchoredImageMdExport) CPPUNIT_TEST_FIXTURE(Test, testTemplateMdImport) { // Given a document with a template: - setImportFilterOptions(uR"json({ + + // When importing that markdown: + createSwDoc("template.md", { + comphelper::makePropertyValue(u"FilterOptions"_ustr, uR"json({ "TemplateURL": { "type": "string", "value": "./template.ott" } -})json"_ustr); - - // When importing that markdown: - createSwDoc("template.md"); +})json"_ustr), + }); // Then make sure the styles are taken from the template: SwDocShell* pDocShell = getSwDocShell(); @@ -968,16 +970,16 @@ CPPUNIT_TEST_FIXTURE(Test, testTemplateMdImport) CPPUNIT_TEST_FIXTURE(Test, testDocxTemplateMdImport) { // Given a document with a DOCX template: - setImportFilterOptions(uR"json({ + // When importing that markdown: + // Without the accompanying fix in place, this crashed. + createSwDoc("template.md", { + comphelper::makePropertyValue(u"FilterOptions"_ustr, uR"json({ "TemplateURL": { "type": "string", "value": "./template.docx" } -})json"_ustr); - - // When importing that markdown: - // Without the accompanying fix in place, this crashed. - createSwDoc("template.md"); +})json"_ustr), + }); // Then make sure the styles are taken from the template: SwDocShell* pDocShell = getSwDocShell(); diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx index 842cd960cff7..3ae500169d69 100644 --- a/sw/qa/inc/swmodeltestbase.hxx +++ b/sw/qa/inc/swmodeltestbase.hxx @@ -196,7 +196,8 @@ protected: * createSwDoc("test.fodt"); * createSwDoc("test.fodt", "test"); */ - void createSwDoc(const char* pName = nullptr, const char* pPassword = nullptr); + void createSwDoc(const char* pName = nullptr, + const css::uno::Sequence<css::beans::PropertyValue>& rParams = {}, const char* pPassword = nullptr); /** * As createSwDoc except a Web Document in Browse Mode @@ -231,7 +232,8 @@ protected: void emulateTyping(std::u16string_view rStr); private: - void loadURL(OUString const& rURL, const char* pPassword = nullptr); + void loadURL(OUString const& rURL, + const css::uno::Sequence<css::beans::PropertyValue>& rParams = {}, const char* pPassword = nullptr); void dumpLayout(SwDoc* pDoc); }; diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx index 36eb4fe7913e..61f720b4b9ff 100644 --- a/sw/qa/unit/swmodeltestbase.cxx +++ b/sw/qa/unit/swmodeltestbase.cxx @@ -372,12 +372,14 @@ uno::Reference<drawing::XShape> SwModelTestBase::getTextFrameByName(const OUStri return xShape; } -void SwModelTestBase::loadURL(OUString const& rURL, const char* pPassword) +void SwModelTestBase::loadURL(OUString const& rURL, + const css::uno::Sequence<css::beans::PropertyValue>& rParams, + const char* pPassword) { // Output name at load time, so in the case of a hang, the name of the hanging input file is visible. std::cout << rURL << ": "; - loadFromURL(rURL, /*rParams*/ {}, pPassword); + loadFromURL(rURL, rParams, pPassword); CPPUNIT_ASSERT(!getSwDocShell()->GetMedium()->GetWarningError()); @@ -390,7 +392,7 @@ void SwModelTestBase::saveAndReload(TestFilter eFilter, { save(eFilter, rParams, pPassword); - loadURL(maTempFile.GetURL(), pPassword); + loadURL(maTempFile.GetURL(), rParams, pPassword); } int SwModelTestBase::getPages() const @@ -411,12 +413,14 @@ int SwModelTestBase::getShapes() const return xDraws->getCount(); } -void SwModelTestBase::createSwDoc(const char* pName, const char* pPassword) +void SwModelTestBase::createSwDoc(const char* pName, + const css::uno::Sequence<css::beans::PropertyValue>& rParams, + const char* pPassword) { if (!pName) loadURL(u"private:factory/swriter"_ustr); else - loadURL(createFileURL(OUString::createFromAscii(pName)), pPassword); + loadURL(createFileURL(OUString::createFromAscii(pName)), rParams, pPassword); uno::Reference<lang::XServiceInfo> xServiceInfo(mxComponent, uno::UNO_QUERY_THROW); CPPUNIT_ASSERT(xServiceInfo->supportsService(u"com.sun.star.text.TextDocument"_ustr)); diff --git a/test/source/unoapi_test.cxx b/test/source/unoapi_test.cxx index e74a14063669..79eef61ab8a8 100644 --- a/test/source/unoapi_test.cxx +++ b/test/source/unoapi_test.cxx @@ -259,9 +259,6 @@ void UnoApiTest::loadFromURL(OUString const& rURL, <<= css::uno::Reference<task::XInteractionHandler2>(xInteractionHandler); } - if (!maImportFilterOptions.isEmpty()) - aMediaDescriptor[u"FilterOptions"_ustr] <<= maImportFilterOptions; - if (meImportFilterName != TestFilter::NONE) aMediaDescriptor[u"FilterName"_ustr] <<= TestFilterNames.at(meImportFilterName); @@ -362,7 +359,7 @@ void UnoApiTest::saveAndReload(TestFilter eFilter, const char* pPassword) { save(eFilter, rParams, pPassword); - loadFromURL(maTempFile.GetURL(), /*rParams*/ {}, pPassword); + loadFromURL(maTempFile.GetURL(), rParams, pPassword); } std::unique_ptr<vcl::pdf::PDFiumDocument> UnoApiTest::parsePDFExport(const OString& rPassword)
