summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-01-29 13:40:21 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2019-01-29 17:02:17 +0100
commit3cacdf5b0f1a6285370d5b06ddec9bce770ea603 (patch)
treebd4fe76fef2f8790120fd7196347c049d920b323 /sc
parent55013f566d540b910a73d6403809cd236f75636c (diff)
sc: fix CppunitTest_sc_ddelinkobj to copy its test document
XRefreshable::testRefreshListener() fails on read-only filesystem because the ScDDELinksObj.ods cannot be loaded read-write. It is loaded read-write since commit 5b2794e27a81f8078cc251580ca59cc47807c7a0. Change-Id: I27b954b216acd3d138ade0d3f1b21fedd2f74fb1 Reviewed-on: https://gerrit.libreoffice.org/67071 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
Diffstat (limited to 'sc')
-rw-r--r--sc/CppunitTest_sc_ddelinkobj.mk1
-rw-r--r--sc/qa/extras/scddelinkobj.cxx32
2 files changed, 28 insertions, 5 deletions
diff --git a/sc/CppunitTest_sc_ddelinkobj.mk b/sc/CppunitTest_sc_ddelinkobj.mk
index c59cf6e96360..60ab216aaca4 100644
--- a/sc/CppunitTest_sc_ddelinkobj.mk
+++ b/sc/CppunitTest_sc_ddelinkobj.mk
@@ -23,6 +23,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_ddelinkobj, \
subsequenttest \
test \
unotest \
+ utl \
vcl \
))
diff --git a/sc/qa/extras/scddelinkobj.cxx b/sc/qa/extras/scddelinkobj.cxx
index 0aa2e968c58e..4d1838a3b321 100644
--- a/sc/qa/extras/scddelinkobj.cxx
+++ b/sc/qa/extras/scddelinkobj.cxx
@@ -12,6 +12,7 @@
#include <test/sheet/xddelink.hxx>
#include <test/util/xrefreshable.hxx>
+#include <unotools/tempfile.hxx>
#include <sfx2/app.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -33,7 +34,29 @@ using namespace com::sun::star;
namespace sc_apitest
{
+static utl::TempFile createTempCopy(OUString const& url)
+{
+ utl::TempFile tmp;
+ tmp.EnableKillingFile();
+ auto const e = osl::File::copy(url, tmp.GetURL());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(
+ (OUStringToOString("<" + url + "> -> <" + tmp.GetURL() + ">", RTL_TEXTENCODING_UTF8)
+ .getStr()),
+ osl::FileBase::E_None, e);
+ return tmp;
+}
+
+struct TempFileBase
+{
+ utl::TempFile m_TempFile;
+ explicit TempFileBase(OUString const& url)
+ : m_TempFile(createTempCopy(url))
+ {
+ }
+};
+
class ScDDELinkObj : public CalcUnoApiTest,
+ public TempFileBase,
public apitest::XDDELink,
public apitest::XNamed,
public apitest::XRefreshable
@@ -67,9 +90,9 @@ private:
ScDDELinkObj::ScDDELinkObj()
: CalcUnoApiTest("/sc/qa/extras/testdocuments")
- , XNamed("soffice|"
- + m_directories.getURLFromSrc("/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods")
- + "!Sheet1.A1")
+ , TempFileBase(m_directories.getURLFromSrc("/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods"))
+ , XDDELink(m_TempFile.GetURL())
+ , XNamed("soffice|" + m_TempFile.GetURL() + "!Sheet1.A1")
{
}
@@ -81,8 +104,7 @@ uno::Reference<uno::XInterface> ScDDELinkObj::init()
uno::Reference<container::XIndexAccess> xIA(xSheets, UNO_QUERY_THROW);
uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), UNO_QUERY_THROW);
- const OUString testdoc
- = m_directories.getURLFromSrc("/sc/qa/unoapi/testdocuments/ScDDELinksObj.ods");
+ const OUString testdoc = m_TempFile.GetURL();
xSheet->getCellByPosition(5, 5)->setFormula("=DDE(\"soffice\";\"" + testdoc
+ "\";\"Sheet1.A1\")");