include/test/unoapi_test.hxx           |    3 +++
 sc/qa/unit/subsequent_export_test2.cxx |   10 ++++++++--
 test/source/unoapi_test.cxx            |   18 ++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)

New commits:
commit 3068163565e8e07bea6ab38a972ae99a47232feb
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Thu Sep 21 07:11:13 2023 -0400
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Tue Oct 31 12:13:59 2023 +0100

    sc: qa: add loadWithParams and SaveWithParams
    
    Add option to load and save with optional parameters.
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: I2d735443da11634d072742f1bf6f38f90bced2c9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157141
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157569
    Tested-by: Jenkins
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158527

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);

Reply via email to