embeddedobj/qa/cppunit/msole.cxx | 3 - filter/qa/unit/textfilterdetect.cxx | 2 framework/qa/cppunit/CheckXTitle.cxx | 6 +- include/test/unoapi_test.hxx | 13 ++-- sc/qa/filter/html/html.cxx | 8 --- sc/qa/unit/helper/qahelper.cxx | 2 sc/qa/unit/subsequent_export_test2.cxx | 2 sc/qa/unit/subsequent_export_test4.cxx | 8 +-- sc/qa/unit/subsequent_filters_test4.cxx | 6 +- sd/qa/unit/sdmodeltestbase.hxx | 4 - sd/qa/unit/tiledrendering/tiledrendering2.cxx | 2 sfx2/qa/cppunit/doc.cxx | 2 svx/qa/unit/svdraw.cxx | 2 sw/qa/core/doc/doc.cxx | 2 sw/qa/core/layout/flycnt.cxx | 2 sw/qa/extras/embedded_fonts/embedded_fonts.cxx | 34 ++++++------ sw/qa/extras/htmlexport/htmlmodeltestbase.hxx | 2 sw/qa/extras/htmlimport/htmlimport.cxx | 3 - sw/qa/extras/layout/layout2.cxx | 3 - sw/qa/extras/layout/layout6.cxx | 9 +-- sw/qa/extras/odfimport/odfimport.cxx | 2 sw/qa/uibase/uiview/uiview.cxx | 2 sw/qa/unit/swmodeltestbase.cxx | 2 test/source/unoapi_test.cxx | 66 +++++++++---------------- vcl/qa/cppunit/filter/ipdf/ipdf.cxx | 2 xmlsecurity/qa/unit/signing/signing.cxx | 34 ++++++------ xmlsecurity/qa/unit/signing/signing2.cxx | 4 - 27 files changed, 99 insertions(+), 128 deletions(-)
New commits: commit 6577d2a942980af030bad168ae1a28fa167e5cde Author: Xisco Fauli <[email protected]> AuthorDate: Thu Feb 12 18:30:06 2026 +0100 Commit: Xisco Fauli <[email protected]> CommitDate: Thu Feb 12 20:58:05 2026 +0100 UnoApiTest: merge loadFromURL and loadWithParams into one Change-Id: Ib58c211542018f07303cadacda86e3419062401e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199297 Tested-by: Jenkins Reviewed-by: Xisco Fauli <[email protected]> diff --git a/embeddedobj/qa/cppunit/msole.cxx b/embeddedobj/qa/cppunit/msole.cxx index 2aacb1ad2ffd..c06c599f8fd0 100644 --- a/embeddedobj/qa/cppunit/msole.cxx +++ b/embeddedobj/qa/cppunit/msole.cxx @@ -100,12 +100,11 @@ CPPUNIT_TEST_FIXTURE(Test, testSaveOnThread) return; DBG_TESTSOLARMUTEX(); - OUString aURL = createFileURL(u"reqif-ole2.xhtml"); uno::Sequence<beans::PropertyValue> aLoadProperties = { comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")), comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")), }; - loadWithParams(aURL, aLoadProperties); + loadFromFile(u"reqif-ole2.xhtml", aLoadProperties); // When saving that document on a thread: OdtExportThread aThread(mxComponent, maTempFile.GetURL()); diff --git a/filter/qa/unit/textfilterdetect.cxx b/filter/qa/unit/textfilterdetect.cxx index 344659d8b11c..135b939d5ea7 100644 --- a/filter/qa/unit/textfilterdetect.cxx +++ b/filter/qa/unit/textfilterdetect.cxx @@ -304,7 +304,7 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testTdf169154) = { comphelper::makePropertyValue(u"RepairPackage"_ustr, true) }; // Without the fix in place, this test would fail to load the file in RepairPackage mode - loadWithParams(createFileURL(u"tdf169154.doc"), aParams); + loadFromFile(u"tdf169154.doc", aParams); CPPUNIT_ASSERT(supportsService(mxComponent, "com.sun.star.text.TextDocument")); } } diff --git a/framework/qa/cppunit/CheckXTitle.cxx b/framework/qa/cppunit/CheckXTitle.cxx index ce66c7379f02..6c96974c40d4 100644 --- a/framework/qa/cppunit/CheckXTitle.cxx +++ b/framework/qa/cppunit/CheckXTitle.cxx @@ -42,7 +42,7 @@ CPPUNIT_TEST_FIXTURE(Test, checkDefaultTitle) // Load document uno::Sequence<beans::PropertyValue> aLoadArgs{ comphelper::makePropertyValue(u"Hidden"_ustr, false) }; - loadWithParams(u"private:factory/swriter"_ustr, aLoadArgs); + loadFromURL(u"private:factory/swriter"_ustr, aLoadArgs); uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); uno::Reference<frame::XController> xController(xModel->getCurrentController()); @@ -85,7 +85,7 @@ CPPUNIT_TEST_FIXTURE(Test, checkTitleSuggestedFileName) uno::Sequence<beans::PropertyValue> aArguments = { comphelper::makePropertyValue(u"SuggestedSaveAsName"_ustr, u"suggestedname.odt"_ustr), comphelper::makePropertyValue(u"Hidden"_ustr, false) }; - loadWithParams(u"private:factory/swriter"_ustr, aArguments); + loadFromURL(u"private:factory/swriter"_ustr, aArguments); uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); uno::Reference<frame::XController> xController(xModel->getCurrentController()); uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); @@ -103,7 +103,7 @@ CPPUNIT_TEST_FIXTURE(Test, setTitleAndCheck) uno::Sequence<beans::PropertyValue> aLoadArgs{ comphelper::makePropertyValue(u"Hidden"_ustr, false) }; - loadWithParams(u"private:factory/swriter"_ustr, aLoadArgs); + loadFromURL(u"private:factory/swriter"_ustr, aLoadArgs); uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); uno::Reference<frame::XController> xController(xModel->getCurrentController()); diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx index 48b3a055c99d..5554cedc3daa 100644 --- a/include/test/unoapi_test.hxx +++ b/include/test/unoapi_test.hxx @@ -138,11 +138,13 @@ public: OUString createFileURL(std::u16string_view aFileBase); OUString createFilePath(std::u16string_view aFileBase); - void loadFromURL(const OUString& rURL, const char* pPassword = nullptr); + void loadFromURL(const OUString& rURL, + const css::uno::Sequence<css::beans::PropertyValue>& rParams = {}, + const char* pPassword = nullptr); void dispose(); - void loadWithParams(const OUString& rURL, - const css::uno::Sequence<css::beans::PropertyValue>& rParams); - OUString loadFromFile(std::u16string_view aFileBase, const char* pPassword = nullptr); + OUString loadFromFile(std::u16string_view aFileBase, + const css::uno::Sequence<css::beans::PropertyValue>& rParams = {}, + const char* pPassword = nullptr); css::uno::Any executeMacro(const OUString& rScriptURL, const css::uno::Sequence<css::uno::Any>& rParams = {}); @@ -180,9 +182,6 @@ protected: rtl::Reference<TestInteractionHandler> xInteractionHandler; private: - void setTestInteractionHandler(const char* pPassword, - std::vector<css::beans::PropertyValue>& rFilterOptions); - void validate(const OUString& rURL, TestFilter eFilter) const; bool mbSkipValidation; diff --git a/sc/qa/filter/html/html.cxx b/sc/qa/filter/html/html.cxx index 2c1d02aab0b5..ee8f1ad17602 100644 --- a/sc/qa/filter/html/html.cxx +++ b/sc/qa/filter/html/html.cxx @@ -40,14 +40,12 @@ public: CPPUNIT_TEST_FIXTURE(Test, testTdAsText) { // Given a document with an A2 cell that contains "02" as text: - OUString aURL = createFileURL(u"text.html"); - // When loading that document to Calc: uno::Sequence<beans::PropertyValue> aParams = { comphelper::makePropertyValue(u"DocumentService"_ustr, u"com.sun.star.sheet.SpreadsheetDocument"_ustr), }; - loadWithParams(aURL, aParams); + loadFromFile(u"text.html", aParams); // Then make sure "01" is not auto-converted to 1, as a number: uno::Reference<sheet::XSpreadsheetDocument> xDocument(mxComponent, uno::UNO_QUERY); @@ -235,14 +233,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf79298_strikeout_variants) CPPUNIT_TEST_FIXTURE(Test, testTdf132770_inserted_text) { // Given a document with an inserted text tag <ins> - OUString aURL = createFileURL(u"tdf132770_inserted_text.html"); - // When loading that document to Calc: uno::Sequence<beans::PropertyValue> aParams = { comphelper::makePropertyValue(u"DocumentService"_ustr, u"com.sun.star.sheet.SpreadsheetDocument"_ustr), }; - loadWithParams(aURL, aParams); + loadFromFile(u"tdf132770_inserted_text.html", aParams); // Verify HTML inserted text tag <ins> ScDocument* pDoc = getScDoc(); diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index d0f381087cac..73fa003745e7 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -612,7 +612,7 @@ void ScModelTestBase::createScDoc(const char* pName, const char* pPassword, bool if (!pName) loadFromURL(u"private:factory/scalc"_ustr); else - loadFromFile(OUString::createFromAscii(pName), pPassword); + loadFromFile(OUString::createFromAscii(pName), /*rParams*/ {}, pPassword); uno::Reference<lang::XServiceInfo> xServiceInfo(mxComponent, uno::UNO_QUERY_THROW); CPPUNIT_ASSERT(xServiceInfo->supportsService(u"com.sun.star.sheet.SpreadsheetDocument"_ustr)); diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 65361c12aba3..56bf56009e97 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -889,7 +889,7 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testOpenDocumentAsReadOnly) uno::Sequence<beans::PropertyValue> aParams = { comphelper::makePropertyValue(u"Silent"_ustr, true) }; - loadWithParams(createFileURL(u"xlsx/open-as-read-only.xlsx"), aParams); + loadFromFile(u"xlsx/open-as-read-only.xlsx", aParams); ScDocShell* pDocSh = getScDocShell(); CPPUNIT_ASSERT(pDocSh->IsSecurityOptOpenReadOnly()); diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index 8e38d23f98ee..341d39aa7423 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -2338,8 +2338,8 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf166939) // Given a document with a column autostyle name equal to "a" (it could be any single-character // name). Load it as template, to keep streams valid (see ScDocShell::SaveAs) to reuse existing // autostyle names (see ScXMLExport::collectAutoStyles). - loadWithParams(createFileURL(u"ods/autostyle-name-is-single-char.ods"), - { comphelper::makePropertyValue(u"AsTemplate"_ustr, true) }); + loadFromFile(u"ods/autostyle-name-is-single-char.ods", + { comphelper::makePropertyValue(u"AsTemplate"_ustr, true) }); // Saving it must not crash / fail an assertion! save(TestFilter::ODS); // Check that we tested the codepath preserving existing names - otherwise test makes no sense @@ -2353,8 +2353,8 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf166939_1) // Check that the autostyles are stored correctly, when autostyle names are not standard (are // not like "ro1"; the chosen names are "r_1", "r_2"). A mistake had made a function return // existing style's index negative, and that wasn't caught in tests... - loadWithParams(createFileURL(u"fods/lostRowStyle.fods"), - { comphelper::makePropertyValue(u"AsTemplate"_ustr, true) }); + loadFromFile(u"fods/lostRowStyle.fods", + { comphelper::makePropertyValue(u"AsTemplate"_ustr, true) }); // Saving it must keep the autostyles save(TestFilter::ODS); xmlDocUniquePtr pXmlDoc = parseExport(u"content.xml"_ustr); diff --git a/sc/qa/unit/subsequent_filters_test4.cxx b/sc/qa/unit/subsequent_filters_test4.cxx index bc2e0992f164..c8bb7e29bdf9 100644 --- a/sc/qa/unit/subsequent_filters_test4.cxx +++ b/sc/qa/unit/subsequent_filters_test4.cxx @@ -124,7 +124,7 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testTdf131575) // importing it must succeed with RepairPackage set to true. uno::Sequence<beans::PropertyValue> aParams = { comphelper::makePropertyValue(u"RepairPackage"_ustr, true) }; - loadWithParams(createFileURL(u"xlsx/tdf131575.xlsx"), aParams); + loadFromFile(u"xlsx/tdf131575.xlsx", aParams); ScDocument* pDoc = getScDoc(); CPPUNIT_ASSERT_EQUAL(u"ETAT DES SORTIES"_ustr, pDoc->GetString(1, 0, 0)); @@ -138,7 +138,7 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testTdf76115) // importing it must succeed with RepairPackage set to true. uno::Sequence<beans::PropertyValue> aParams = { comphelper::makePropertyValue(u"RepairPackage"_ustr, true) }; - loadWithParams(createFileURL(u"xlsx/tdf76115.xlsx"), aParams); + loadFromFile(u"xlsx/tdf76115.xlsx", aParams); ScDocument* pDoc = getScDoc(); CPPUNIT_ASSERT_EQUAL(u"Filial"_ustr, pDoc->GetString(0, 0, 0)); @@ -1657,7 +1657,7 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testForcepoint107) // importing it must succeed with RepairPackage set to true. uno::Sequence<beans::PropertyValue> aParams = { comphelper::makePropertyValue(u"RepairPackage"_ustr, true) }; - loadWithParams(createFileURL(u"xlsx/forcepoint107.xlsx"), aParams); + loadFromFile(u"xlsx/forcepoint107.xlsx", aParams); ScDocShell* pDocSh = getScDocShell(); pDocSh->DoHardRecalc(); diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index 135245767d03..e80fce16bc0c 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -53,7 +53,7 @@ public: if (!pName) loadFromURL(u"private:factory/simpress"_ustr); else - loadFromFile(OUString::createFromAscii(pName), pPassword); + loadFromFile(OUString::createFromAscii(pName), /*rParams*/ {}, pPassword); uno::Reference<lang::XServiceInfo> xServiceInfo(mxComponent, uno::UNO_QUERY_THROW); CPPUNIT_ASSERT( @@ -67,7 +67,7 @@ public: if (!pName) loadFromURL(u"private:factory/sdraw"_ustr); else - loadFromFile(OUString::createFromAscii(pName), pPassword); + loadFromFile(OUString::createFromAscii(pName), /*rParams*/ {}, pPassword); uno::Reference<lang::XServiceInfo> xServiceInfo(mxComponent, uno::UNO_QUERY_THROW); CPPUNIT_ASSERT(xServiceInfo->supportsService(u"com.sun.star.drawing.DrawingDocument"_ustr)); diff --git a/sd/qa/unit/tiledrendering/tiledrendering2.cxx b/sd/qa/unit/tiledrendering/tiledrendering2.cxx index 2336c46e886d..269e3fea3de9 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering2.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering2.cxx @@ -52,7 +52,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testInsertSignatureLineExternal) // Given a PDF to be signed: uno::Sequence<beans::PropertyValue> aArgs = { comphelper::makePropertyValue("ReadOnly", true) }; createTempCopy(u"empty.pdf"); - loadWithParams(maTempFile.GetURL(), aArgs); + loadFromURL(maTempFile.GetURL(), aArgs); SdXImpressDocument* pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); pImpressDocument->initializeForTiledRendering({}); sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell(); diff --git a/sfx2/qa/cppunit/doc.cxx b/sfx2/qa/cppunit/doc.cxx index 14fb50e09e2c..28de9ef30806 100644 --- a/sfx2/qa/cppunit/doc.cxx +++ b/sfx2/qa/cppunit/doc.cxx @@ -43,7 +43,7 @@ CPPUNIT_TEST_FIXTURE(Test, testNoGrabBagShape) // Load a document and select the first shape. css::uno::Sequence<css::beans::PropertyValue> aArgs{ comphelper::makePropertyValue( u"ReadOnly"_ustr, true) }; - loadWithParams(u"private:factory/simpress"_ustr, aArgs); + loadFromURL(u"private:factory/simpress"_ustr, aArgs); uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xModel, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDrawPage( diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx index a8dc438553ba..dfd594e2d7d1 100644 --- a/svx/qa/unit/svdraw.cxx +++ b/svx/qa/unit/svdraw.cxx @@ -887,7 +887,7 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testVisualSignResize) #if ENABLE_PDFIMPORT // Given a read-only document with a just inserted signature line: uno::Sequence<beans::PropertyValue> aArgs = { comphelper::makePropertyValue("ReadOnly", true) }; - loadWithParams(createFileURL(u"empty.pdf"), aArgs); + loadFromFile(u"empty.pdf", aArgs); SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); CPPUNIT_ASSERT(pBaseModel); SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index eca5889054f0..f60c556ca425 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -676,7 +676,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testAtCharImageCopy) pWrtShell1->SelAll(); rtl::Reference<SwTransferable> xTransfer = new SwTransferable(*pWrtShell1); xTransfer->Copy(); - // Don't use createSwDoc(), UnoApiTest::loadWithParams() would dispose the first document. + // Don't use createSwDoc(), UnoApiTest::loadFromURL() would dispose the first document. mxComponent2 = loadFromDesktop(u"private:factory/swriter"_ustr); // When copying the body text from that document to a new one: diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 7e871fde386b..aae2fb2bcdbe 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), }; - loadWithParams(createFileURL(u"floattable-then-table.docx"), aFilterOptions); + loadFromFile(u"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 903964daf63a..523b060e5646 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)); - loadWithParams(createFileURL(u"embed-restricted-style+autostyle.odt"), - { comphelper::makePropertyValue( - u"InteractionHandler"_ustr, - uno::Reference<task::XInteractionHandler>(xInteraction)) }); + loadFromFile(u"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)); - loadWithParams(createFileURL(u"embed-restricted-style+autostyle.odt"), - { comphelper::makePropertyValue( - u"InteractionHandler"_ustr, - uno::Reference<task::XInteractionHandler>(xInteraction)) }); + loadFromFile(u"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()); @@ -246,7 +246,7 @@ CPPUNIT_TEST_FIXTURE(Test, testOpenDOCXWithRestrictedEmbeddedFont) // 1. Load without interaction handler. It must not load the restricted font; // unrestricted one must load. FontMappingUseListener fontMappingData; - loadWithParams(createFileURL(u"embed-restricted+unrestricted.docx"), {}); + loadFromFile(u"embed-restricted+unrestricted.docx"); // The document is editable: CPPUNIT_ASSERT(!getSwDocShell()->IsReadOnly()); @@ -276,10 +276,10 @@ CPPUNIT_TEST_FIXTURE(Test, testOpenDOCXWithRestrictedEmbeddedFont) // unrestricted one must load. FontMappingUseListener fontMappingData; rtl::Reference xInteraction(new FontInteractionHandler(false)); - loadWithParams(createFileURL(u"embed-restricted+unrestricted.docx"), - { comphelper::makePropertyValue( - u"InteractionHandler"_ustr, - uno::Reference<task::XInteractionHandler>(xInteraction)) }); + loadFromFile(u"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)); - loadWithParams(createFileURL(u"embed-restricted+unrestricted.docx"), - { comphelper::makePropertyValue( - u"InteractionHandler"_ustr, - uno::Reference<task::XInteractionHandler>(xInteraction)) }); + loadFromFile(u"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/htmlexport/htmlmodeltestbase.hxx b/sw/qa/extras/htmlexport/htmlmodeltestbase.hxx index 9cfcbcd0db4f..3424075d6f63 100644 --- a/sw/qa/extras/htmlexport/htmlmodeltestbase.hxx +++ b/sw/qa/extras/htmlexport/htmlmodeltestbase.hxx @@ -219,7 +219,7 @@ void SwHtmlDomExportTest::ImportFromReqif(const OUString& rUrl) comphelper::makePropertyValue(u"FilterName"_ustr, u"HTML (StarWriter)"_ustr), comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), }; - loadWithParams(rUrl, aLoadProperties); + loadFromURL(rUrl, aLoadProperties); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 0fcc747f310f..12534e8a9e8a 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -491,8 +491,7 @@ CPPUNIT_TEST_FIXTURE(SwHtmlOptionsImportTest, testAllowedRTFOLEMimeTypes) comphelper::makePropertyValue(u"FilterOptions"_ustr, u"xhtmlns=reqif-xhtml"_ustr), comphelper::makePropertyValue(u"AllowedRTFOLEMimeTypes"_ustr, aTypes), }; - OUString aURL = createFileURL(u"allowed-rtf-ole-mime-types.xhtml"); - loadWithParams(aURL, aLoadProperties); + loadFromFile(u"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); diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index e4cdec863d79..b4fa380c32e1 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -1521,8 +1521,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTableCellInvalidate) }; // inline the loading because currently properties can't be passed... - OUString const url(createFileURL(u"table_cell_overlap.fodt")); - loadWithParams(url, comphelper::containerToSequence(aFilterOptions)); + loadFromFile(u"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 7022d355f9af..26c7044f9674 100644 --- a/sw/qa/extras/layout/layout6.cxx +++ b/sw/qa/extras/layout/layout6.cxx @@ -683,8 +683,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter6, testTdf122607_regression) }; // inline the loading because currently properties can't be passed... - OUString const url(createFileURL(u"tdf122607_leerzeile.odt")); - loadWithParams(url, comphelper::containerToSequence(aFilterOptions)); + loadFromFile(u"tdf122607_leerzeile.odt", comphelper::containerToSequence(aFilterOptions)); save(TestFilter::PDF_WRITER); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); @@ -711,8 +710,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter6, TestTdf150616) }; // inline the loading because currently properties can't be passed... - OUString const url(createFileURL(u"in_056132_mod.odt")); - loadWithParams(url, comphelper::containerToSequence(aFilterOptions)); + loadFromFile(u"in_056132_mod.odt", comphelper::containerToSequence(aFilterOptions)); save(TestFilter::PDF_WRITER); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); @@ -1521,8 +1519,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter6, testTdf156724) }; // inline the loading because currently properties can't be passed... - OUString const url(createFileURL(u"fdo56797-2-min.odt")); - loadWithParams(url, comphelper::containerToSequence(aFilterOptions)); + loadFromFile(u"fdo56797-2-min.odt", comphelper::containerToSequence(aFilterOptions)); save(TestFilter::PDF_WRITER); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 7ed50f8f0677..d8f4a6cfccd6 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -1534,7 +1534,7 @@ CPPUNIT_TEST_FIXTURE(Test, testBrokenPackage_Tdf159474) // It expectedly fails to load normally: CPPUNIT_ASSERT_ASSERTION_FAIL(loadFromURL(url)); // importing it must succeed with RepairPackage set to true. - loadWithParams(url, { comphelper::makePropertyValue(u"RepairPackage"_ustr, true) }); + loadFromURL(url, { comphelper::makePropertyValue(u"RepairPackage"_ustr, true) }); // The document imports in repair mode; the original broken package is used as a template, // and the loaded document has no URL: CPPUNIT_ASSERT(mxComponent.queryThrow<frame::XModel>()->getURL().isEmpty()); diff --git a/sw/qa/uibase/uiview/uiview.cxx b/sw/qa/uibase/uiview/uiview.cxx index ff6e777d1325..3fb6d5a10cbb 100644 --- a/sw/qa/uibase/uiview/uiview.cxx +++ b/sw/qa/uibase/uiview/uiview.cxx @@ -106,7 +106,7 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testUpdateReplacementNosetting) // Load a copy of the document in hidden mode. OUString aSourceURL = createFileURL(u"update-replacement-nosetting.odt"); CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, osl::File::copy(aSourceURL, maTempFile.GetURL())); - loadWithParams(maTempFile.GetURL(), { comphelper::makePropertyValue(u"Hidden"_ustr, true) }); + loadFromURL(maTempFile.GetURL(), { comphelper::makePropertyValue(u"Hidden"_ustr, true) }); // Update "everything" (including object replacements) and save it. dispatchCommand(mxComponent, u".uno:UpdateAll"_ustr, {}); diff --git a/sw/qa/unit/swmodeltestbase.cxx b/sw/qa/unit/swmodeltestbase.cxx index ae42c7c3264d..36eb4fe7913e 100644 --- a/sw/qa/unit/swmodeltestbase.cxx +++ b/sw/qa/unit/swmodeltestbase.cxx @@ -377,7 +377,7 @@ void SwModelTestBase::loadURL(OUString const& rURL, 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, pPassword); + loadFromURL(rURL, /*rParams*/ {}, pPassword); CPPUNIT_ASSERT(!getSwDocShell()->GetMedium()->GetWarningError()); diff --git a/test/source/unoapi_test.cxx b/test/source/unoapi_test.cxx index e5f4758b9fe4..e74a14063669 100644 --- a/test/source/unoapi_test.cxx +++ b/test/source/unoapi_test.cxx @@ -76,17 +76,6 @@ OUString UnoApiTest::createFilePath(std::u16string_view aFileBase) return m_directories.getPathFromSrc(m_aBaseString, aFileBase); } -void UnoApiTest::setTestInteractionHandler(const char* pPassword, - std::vector<beans::PropertyValue>& rFilterOptions) -{ - OUString sPassword = OUString::createFromAscii(pPassword); - auto& rPropertyValue = rFilterOptions.emplace_back(); - xInteractionHandler - = rtl::Reference<TestInteractionHandler>(new TestInteractionHandler(sPassword)); - rPropertyValue.Name = "InteractionHandler"; - rPropertyValue.Value <<= css::uno::Reference<task::XInteractionHandler2>(xInteractionHandler); -} - #if HAVE_EXPORT_VALIDATION namespace { @@ -252,32 +241,38 @@ void UnoApiTest::validate(const OUString& rPath, TestFilter eFilter) const #endif } -void UnoApiTest::loadFromURL(OUString const& rURL, const char* pPassword) +void UnoApiTest::loadFromURL(OUString const& rURL, + const uno::Sequence<beans::PropertyValue>& rParams, + const char* pPassword) { - std::vector<beans::PropertyValue> aFilterOptions; + comphelper::SequenceAsHashMap aMediaDescriptor; + + if (rParams.hasElements()) + aMediaDescriptor.update(rParams); if (pPassword) { - setTestInteractionHandler(pPassword, aFilterOptions); + OUString sPassword = OUString::createFromAscii(pPassword); + xInteractionHandler + = rtl::Reference<TestInteractionHandler>(new TestInteractionHandler(sPassword)); + aMediaDescriptor["InteractionHandler"] + <<= css::uno::Reference<task::XInteractionHandler2>(xInteractionHandler); } if (!maImportFilterOptions.isEmpty()) - { - beans::PropertyValue aValue; - aValue.Name = "FilterOptions"; - aValue.Value <<= maImportFilterOptions; - aFilterOptions.push_back(aValue); - } + aMediaDescriptor[u"FilterOptions"_ustr] <<= maImportFilterOptions; if (meImportFilterName != TestFilter::NONE) + aMediaDescriptor[u"FilterName"_ustr] <<= TestFilterNames.at(meImportFilterName); + + if (mxComponent.is()) { - beans::PropertyValue aValue; - aValue.Name = "FilterName"; - aValue.Value <<= TestFilterNames.at(meImportFilterName); - aFilterOptions.push_back(aValue); + mxComponent->dispose(); + mxComponent.clear(); } - loadWithParams(rURL, comphelper::containerToSequence(aFilterOptions)); + mxComponent = loadFromDesktop(rURL, OUString(), aMediaDescriptor.getAsConstPropertyValueList()); + CPPUNIT_ASSERT(mxComponent); if (pPassword) { @@ -292,23 +287,12 @@ void UnoApiTest::dispose() mxComponent.clear(); } -void UnoApiTest::loadWithParams(OUString const& rURL, - const uno::Sequence<beans::PropertyValue>& rParams) -{ - if (mxComponent.is()) - { - mxComponent->dispose(); - mxComponent.clear(); - } - - mxComponent = loadFromDesktop(rURL, OUString(), rParams); - CPPUNIT_ASSERT(mxComponent); -} - -OUString UnoApiTest::loadFromFile(std::u16string_view aFileBase, const char* pPassword) +OUString UnoApiTest::loadFromFile(std::u16string_view aFileBase, + const css::uno::Sequence<css::beans::PropertyValue>& rParams, + const char* pPassword) { OUString aFileName = createFileURL(aFileBase); - loadFromURL(aFileName, pPassword); + loadFromURL(aFileName, rParams, pPassword); return aFileName; } @@ -378,7 +362,7 @@ void UnoApiTest::saveAndReload(TestFilter eFilter, const char* pPassword) { save(eFilter, rParams, pPassword); - loadFromURL(maTempFile.GetURL(), pPassword); + loadFromURL(maTempFile.GetURL(), /*rParams*/ {}, pPassword); } std::unique_ptr<vcl::pdf::PDFiumDocument> UnoApiTest::parsePDFExport(const OString& rPassword) diff --git a/vcl/qa/cppunit/filter/ipdf/ipdf.cxx b/vcl/qa/cppunit/filter/ipdf/ipdf.cxx index fdd3e75a3dcf..148b3f0ee883 100644 --- a/vcl/qa/cppunit/filter/ipdf/ipdf.cxx +++ b/vcl/qa/cppunit/filter/ipdf/ipdf.cxx @@ -67,7 +67,7 @@ CPPUNIT_TEST_FIXTURE(VclFilterIpdfTest, testPDFAddVisibleSignatureLastPage) // Open it. uno::Sequence<beans::PropertyValue> aArgs = { comphelper::makePropertyValue(u"ReadOnly"_ustr, true) }; - loadWithParams(maTempFile.GetURL(), aArgs); + loadFromURL(maTempFile.GetURL(), aArgs); SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); CPPUNIT_ASSERT(pBaseModel); SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx index ade0030d4798..f78c06d259df 100644 --- a/xmlsecurity/qa/unit/signing/signing.cxx +++ b/xmlsecurity/qa/unit/signing/signing.cxx @@ -751,7 +751,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPDFAddVisibleSignature) // Open it. uno::Sequence<beans::PropertyValue> aArgs = { comphelper::makePropertyValue(u"ReadOnly"_ustr, true) }; - loadWithParams(maTempFile.GetURL(), aArgs); + loadFromURL(maTempFile.GetURL(), aArgs); SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); CPPUNIT_ASSERT(pBaseModel); SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); @@ -1297,7 +1297,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testInvalidZIP) uno::Sequence<beans::PropertyValue> args = { comphelper::makePropertyValue( u"InteractionHandler"_ustr, uno::Reference<task::XInteractionHandler>(pIH)) }; - loadWithParams(createFileURL(u"signature-forgery-cdh-lfh.docx"), args); + loadFromFile(u"signature-forgery-cdh-lfh.docx", args); SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get()); CPPUNIT_ASSERT(pBaseModel); SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell(); @@ -1402,8 +1402,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPreserveMacroTemplateSignature12_ODF) const OUString sLoadMessage = "loading failed: " + aURL; // load the template as-is to validate signatures - loadWithParams(aURL, - comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); + loadFromURL(aURL, comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); // we are a template, and have a valid document and macro signature assertDocument(CPPUNIT_SOURCELINE(), TestFilter::OTT, SignatureState::OK, @@ -1430,8 +1429,8 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPreserveMacroTemplateSignature12_ODF) save(eFormat); // load the saved OTT template as-is to validate signatures - loadWithParams(maTempFile.GetURL(), - comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); + loadFromURL(maTempFile.GetURL(), + comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); } // the loaded document is a OTT/ODT with a macro signature @@ -1442,8 +1441,8 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPreserveMacroTemplateSignature12_ODF) save(TestFilter::OTT); // load the template as-is to validate signatures - loadWithParams(maTempFile.GetURL(), - comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); + loadFromURL(maTempFile.GetURL(), + comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); // the loaded document is a OTT with a valid macro signature assertDocument(CPPUNIT_SOURCELINE(), TestFilter::OTT, SignatureState::NOSIGNATURES, @@ -1458,7 +1457,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testDropMacroTemplateSignature) const OUString sLoadMessage = "loading failed: " + aURL; // load the template as-is to validate signatures - loadWithParams(aURL, comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); + loadFromURL(aURL, comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); // we are a template, and have a non-invalid macro signature assertDocument(CPPUNIT_SOURCELINE(), TestFilter::OTT, SignatureState::NOSIGNATURES, @@ -1481,7 +1480,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testDropMacroTemplateSignature) SignatureState::NOSIGNATURES, ODFVER_014_TEXT); // load the template as-is to validate signatures - loadWithParams(aURL, comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); + loadFromURL(aURL, comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); // we are a template, and have a non-invalid macro signature assertDocument(CPPUNIT_SOURCELINE(), TestFilter::OTT, SignatureState::NOSIGNATURES, @@ -1491,8 +1490,8 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testDropMacroTemplateSignature) save(TestFilter::OTT); // load the template as-is to validate signatures - loadWithParams(maTempFile.GetURL(), - comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); + loadFromURL(maTempFile.GetURL(), + comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); // the loaded document is a 1.2 OTT without any signatures assertDocument(CPPUNIT_SOURCELINE(), TestFilter::OTT, SignatureState::NOSIGNATURES, @@ -1514,8 +1513,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPreserveMacroTemplateSignature10) const OUString sLoadMessage = "loading failed: " + aURL; // load the template as-is to validate signatures - loadWithParams(aURL, - comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); + loadFromURL(aURL, comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); // we are a template, and have a non-invalid macro signature assertDocument(CPPUNIT_SOURCELINE(), TestFilter::OTT, SignatureState::NOSIGNATURES, @@ -1542,8 +1540,8 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPreserveMacroTemplateSignature10) save(TestFilter::OTT); // load the saved OTT template as-is to validate signatures - loadWithParams(maTempFile.GetURL(), - comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); + loadFromURL(maTempFile.GetURL(), + comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); } assertDocument(CPPUNIT_SOURCELINE(), eFormat, SignatureState::NOSIGNATURES, @@ -1552,8 +1550,8 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPreserveMacroTemplateSignature10) save(TestFilter::OTT); // load the template as-is to validate signatures - loadWithParams(maTempFile.GetURL(), - comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); + loadFromURL(maTempFile.GetURL(), + comphelper::InitPropertySequence({ { "AsTemplate", uno::Any(false) } })); // the loaded document is a OTT with a non-invalid macro signature assertDocument(CPPUNIT_SOURCELINE(), TestFilter::OTT, SignatureState::NOSIGNATURES, diff --git a/xmlsecurity/qa/unit/signing/signing2.cxx b/xmlsecurity/qa/unit/signing/signing2.cxx index 58cd7a4618a6..84a268fd2107 100644 --- a/xmlsecurity/qa/unit/signing/signing2.cxx +++ b/xmlsecurity/qa/unit/signing/signing2.cxx @@ -112,7 +112,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest2, testPreserveMacroSignatureODB) CPPUNIT_TEST_FIXTURE(SigningTest2, testPasswordPreserveMacroSignatureODF13) { // load ODF 1.3 encrypted document - loadFromFile(u"encrypted_scriptsig_odf13.odt", "password"); + loadFromFile(u"encrypted_scriptsig_odf13.odt", /*rParams*/ {}, "password"); { uno::Reference<text::XTextDocument> xTextDoc(mxComponent, uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(u"secret"_ustr, xTextDoc->getText()->getString()); @@ -235,7 +235,7 @@ CPPUNIT_TEST_FIXTURE(SigningTest2, testPasswordPreserveMacroSignatureODF13) CPPUNIT_TEST_FIXTURE(SigningTest2, testPasswordPreserveMacroSignatureODFWholesomeLO242) { // load wholesome ODF (extended) encrypted document - loadFromFile(u"encrypted_scriptsig_lo242.odt", "password"); + loadFromFile(u"encrypted_scriptsig_lo242.odt", /*rParams*/ {}, "password"); { uno::Reference<text::XTextDocument> xTextDoc(mxComponent, uno::UNO_QUERY_THROW); CPPUNIT_ASSERT_EQUAL(u"secret"_ustr, xTextDoc->getText()->getString());
