summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-10-20 14:54:44 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-10-20 19:59:29 +0200
commit4856b94ae1d851546b2a95622f78af8b1be798a6 (patch)
tree51ee9ada6e5631d9079c58f4aa86b0ef6d2a011e /test
parentb814c51ef7642f1a54294f945465e7d657533b4e (diff)
CalcUnoApiTest: factor out common code
Change-Id: I1a56f152d6c6e6bca55ef20d0d52da2d82b77a8f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141565 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'test')
-rw-r--r--test/source/calc_unoapi_test.cxx25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/source/calc_unoapi_test.cxx b/test/source/calc_unoapi_test.cxx
index 1aaed35f3fb5..fc8cae982bea 100644
--- a/test/source/calc_unoapi_test.cxx
+++ b/test/source/calc_unoapi_test.cxx
@@ -10,6 +10,10 @@
#include <test/calc_unoapi_test.hxx>
#include <sfx2/objsh.hxx>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <comphelper/propertyvalue.hxx>
+
using namespace css;
using namespace css::uno;
@@ -49,4 +53,25 @@ uno::Any CalcUnoApiTest::executeMacro(const OUString& rScriptURL, const uno::Seq
return aRet;
}
+
+utl::TempFileNamed CalcUnoApiTest::save(const OUString& rFilter)
+{
+ utl::TempFileNamed aTempFile;
+ aTempFile.EnableKillingFile();
+ uno::Sequence aArgs{ comphelper::makePropertyValue("FilterName", rFilter) };
+ css::uno::Reference<frame::XStorable> xStorable(mxComponent, css::uno::UNO_QUERY_THROW);
+ xStorable->storeAsURL(aTempFile.GetURL(), aArgs);
+ css::uno::Reference<util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW);
+ xCloseable->close(true);
+
+ return aTempFile;
+}
+
+void CalcUnoApiTest::saveAndReload(const OUString& rFilter)
+{
+ utl::TempFileNamed aTempFile = save(rFilter);
+
+ mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.sheet.SpreadsheetDocument");
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */