diff options
-rw-r--r-- | include/test/unoapi_test.hxx | 3 | ||||
-rw-r--r-- | sc/qa/unit/subsequent_export_test2.cxx | 10 | ||||
-rw-r--r-- | test/source/unoapi_test.cxx | 18 |
3 files changed, 29 insertions, 2 deletions
diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx index e329168dfe7b..4ba209c44d39 100644 --- a/include/test/unoapi_test.hxx +++ b/include/test/unoapi_test.hxx @@ -36,12 +36,15 @@ public: OUString createFileURL(std::u16string_view aFileBase); OUString createFilePath(std::u16string_view aFileBase); void load(const OUString& rURL, const char* pPassword = nullptr); + void loadWithParams(const OUString& rURL, + const css::uno::Sequence<css::beans::PropertyValue>& rParams); OUString loadFromURL(std::u16string_view aFileBase, const char* pPassword = nullptr); css::uno::Any executeMacro(const OUString& rScriptURL, const css::uno::Sequence<css::uno::Any>& rParams = {}); void save(const OUString& rFilter, const char* pPassword = nullptr); + void saveWithParams(const css::uno::Sequence<css::beans::PropertyValue>& rParams); void saveAndReload(const OUString& rFilter, 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 403bffc3112f..91309d9e5491 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -18,6 +18,7 @@ #include <editeng/editobj.hxx> #include <editeng/flditem.hxx> #include <comphelper/scopeguard.hxx> +#include <comphelper/propertyvalue.hxx> #include <unotools/syslocaleoptions.hxx> #include <formula/grammar.hxx> #include <svl/numformat.hxx> @@ -698,10 +699,15 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testHyperlinkTargetFrameODS) CPPUNIT_TEST_FIXTURE(ScExportTest2, testOpenDocumentAsReadOnly) { - createScDoc("xlsx/open-as-read-only.xlsx"); + uno::Sequence<beans::PropertyValue> aParams = { comphelper::makePropertyValue("Silent", true) }; + + loadWithParams(createFileURL(u"xlsx/open-as-read-only.xlsx"), aParams); ScDocShell* pDocSh = getScDocShell(); CPPUNIT_ASSERT(pDocSh->IsSecurityOptOpenReadOnly()); - saveAndReload("Calc Office Open XML"); + + saveWithParams(uno::Sequence<beans::PropertyValue>()); + loadWithParams(maTempFile.GetURL(), aParams); + pDocSh = getScDocShell(); CPPUNIT_ASSERT(pDocSh->IsSecurityOptOpenReadOnly()); } diff --git a/test/source/unoapi_test.cxx b/test/source/unoapi_test.cxx index 5c689bfe5354..464f374201bd 100644 --- a/test/source/unoapi_test.cxx +++ b/test/source/unoapi_test.cxx @@ -121,6 +121,18 @@ void UnoApiTest::load(OUString const& rURL, const char* pPassword) } } +void UnoApiTest::loadWithParams(OUString const& rURL, + const uno::Sequence<beans::PropertyValue>& rParams) +{ + if (mxComponent.is()) + { + mxComponent->dispose(); + mxComponent.clear(); + } + + mxComponent = loadFromDesktop(rURL, OUString(), rParams); +} + OUString UnoApiTest::loadFromURL(std::u16string_view aFileBase, const char* pPassword) { OUString aFileName = createFileURL(aFileBase); @@ -203,6 +215,12 @@ void UnoApiTest::save(const OUString& rFilter, const char* pPassword) } } +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); +} + void UnoApiTest::saveAndReload(const OUString& rFilter, const char* pPassword) { save(rFilter, pPassword); |