From aeb43916366b293935314efe9454c66b4877b9d1 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Fri, 4 Mar 2016 23:01:18 +0100 Subject: basic: tdf#87530 don't copy storage that doesn't exist If the Basic library is newly created it may not have been stored to the document storage yet. (regression from 5246fa262450f686674850c53df666422f441c86) Change-Id: I9c2fc1d7446795b9c1c2224671118b2a671dcad8 --- sw/qa/core/macros-test.cxx | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'sw') diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx index 687ac8661103..ab9203e0faae 100644 --- a/sw/qa/core/macros-test.cxx +++ b/sw/qa/core/macros-test.cxx @@ -86,6 +86,7 @@ public: #endif void testFdo55289(); void testFdo68983(); + void testFdo87530(); void testFindReplace(); CPPUNIT_TEST_SUITE(SwMacrosTest); #if !defined(MACOSX) && !defined(_WIN32) @@ -101,6 +102,7 @@ public: #endif CPPUNIT_TEST(testFdo55289); CPPUNIT_TEST(testFdo68983); + CPPUNIT_TEST(testFdo87530); CPPUNIT_TEST(testFindReplace); CPPUNIT_TEST_SUITE_END(); @@ -431,6 +433,51 @@ void SwMacrosTest::testFdo68983() xDocCloseable->close(false); } +void SwMacrosTest::testFdo87530() +{ + Reference xComponent = + loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument"); + + { + Reference xDocScr(xComponent, UNO_QUERY_THROW); + Reference xStorBasLib(xDocScr->getBasicLibraries()); + Reference xBasLib(xStorBasLib, UNO_QUERY_THROW); + Reference xBasLibPwd(xStorBasLib, UNO_QUERY_THROW); + xBasLib->createLibrary("Library1"); + xBasLibPwd->changeLibraryPassword("Library1", "", "foo"); + } + + Reference xDocStorable(xComponent, UNO_QUERY_THROW); + CPPUNIT_ASSERT(xDocStorable.is()); + + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + Sequence desc(1); + desc[0].Name = "FilterName"; + desc[0].Value <<= OUString("writer8"); + xDocStorable->storeAsURL(aTempFile.GetURL(), desc); + + Reference(xComponent, UNO_QUERY_THROW)->close(false); + + // re-load + xComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument"); + + // check that password-protected library survived store and re-load + Reference xDocScr(xComponent, UNO_QUERY_THROW); + Reference xStorBasLib(xDocScr->getBasicLibraries()); + Reference xBasLib(xStorBasLib, UNO_QUERY_THROW); + Reference xBasLibPwd(xStorBasLib, UNO_QUERY_THROW); + CPPUNIT_ASSERT(xBasLibPwd->isLibraryPasswordProtected("Library1")); + CPPUNIT_ASSERT(xBasLibPwd->verifyLibraryPassword("Library1", "foo")); + xBasLib->loadLibrary("Library1"); + CPPUNIT_ASSERT(xBasLib->isLibraryLoaded("Library1")); + + // close + Reference xDocCloseable(xComponent, UNO_QUERY_THROW); + xDocCloseable->close(false); +} + + void SwMacrosTest::testFindReplace() { // we need a full document with view and layout etc. because ::GetNode() -- cgit