summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-09-21 07:11:13 -0400
committerHenry Castro <hcastro@collabora.com>2023-10-06 15:27:35 +0200
commitdf9f94a1b37d26b74d981dc4514255c46477c8ac (patch)
treead98824223046af019e0acfd68e95325aebb7798
parentd852e411b52cda24f2d79070798a2fa662bb71f1 (diff)
sc: qa: add loadWithParams and SaveWithParams
Add option to load and save with optional parameters. Signed-off-by: Henry Castro <hcastro@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
-rw-r--r--include/test/unoapi_test.hxx3
-rw-r--r--sc/qa/unit/subsequent_export_test2.cxx10
-rw-r--r--test/source/unoapi_test.cxx18
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);