diff options
author | Michael Stahl <mstahl@redhat.com> | 2014-05-21 22:26:05 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-05-22 10:23:42 -0500 |
commit | 9d2b0fd3424eaf8a685728aa7788e1148159714d (patch) | |
tree | 3bcf0d24931ab408dc9c32eed6f96a51ce130a80 /sw | |
parent | adfd7805bc61ff4ec56f6570fc516ff3aad74a28 (diff) |
fdo#68983: basic: if the library is not loaded fully, copy source storage
Also fixes fdo#42899 and fdo#67685 in a different way; the previous fix
for fdo#42899 caused the problem with password-protected libraries for
which the password is not known: only the binary representation of the
BAISC module was stored, not the source code; by simply copying from the
source storage the problem can be avoided.
It would be possible to ask for the password when storing, but that
would not work when non-interactive (called via API).
An alternative fix would be to pass in the
SfxObjectShell::IsSetModifyEnabled() flag and actually reset the BASIC
library's modify flag correctly, but that requires adding a
parameter to XStorageBasedLibraryContainer::storeLibrariesToStorage().
(regression from af34774d260a68fc02cd78ba90dd8d4afaf1a2a4 )
(cherry picked from commit 5246fa262450f686674850c53df666422f441c86)
Conflicts:
basic/source/inc/namecont.hxx
basic/source/inc/scriptcont.hxx
basic/source/uno/namecont.cxx
sw/CppunitTest_sw_macros_test.mk
sw: use xsec_xmlsec.windows on WNT
(cherry picked from commit 3e69b7bcd3e4a9cb1a29360c905e7fba96365999)
Change-Id: I4701401f35171139fc2fe8d225d13d4e533091a0
Reviewed-on: https://gerrit.libreoffice.org/9437
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/CppunitTest_sw_macros_test.mk | 62 | ||||
-rw-r--r-- | sw/qa/core/data/odt/fdo68983.odt | bin | 0 -> 10510 bytes | |||
-rw-r--r-- | sw/qa/core/macros-test.cxx | 48 |
3 files changed, 80 insertions, 30 deletions
diff --git a/sw/CppunitTest_sw_macros_test.mk b/sw/CppunitTest_sw_macros_test.mk index 819e0f872196..8cda906365da 100644 --- a/sw/CppunitTest_sw_macros_test.mk +++ b/sw/CppunitTest_sw_macros_test.mk @@ -68,36 +68,38 @@ $(eval $(call gb_CppunitTest_use_api,sw_macros_test,\ $(eval $(call gb_CppunitTest_use_ure,sw_macros_test)) $(eval $(call gb_CppunitTest_use_components,sw_macros_test,\ - basic/util/sb \ - comphelper/util/comphelp \ - configmgr/source/configmgr \ - dbaccess/util/dba \ - filter/source/config/cache/filterconfig1 \ - forms/util/frm \ - framework/util/fwk \ - i18npool/util/i18npool \ - oox/util/oox \ - package/source/xstor/xstor \ - package/util/package2 \ - sax/source/expatwrap/expwrap \ - sax/source/fastparser/fastsax \ - sw/util/sw \ - sw/util/swd \ - sw/util/msword \ - sw/util/vbaswobj \ - scripting/source/basprov/basprov \ - scripting/util/scriptframe \ - sfx2/util/sfx \ - sot/util/sot \ - svl/source/fsstor/fsstorage \ - svtools/util/svt \ - toolkit/util/tk \ - ucb/source/core/ucb1 \ - ucb/source/ucp/file/ucpfile1 \ - ucb/source/ucp/tdoc/ucptdoc1 \ - unotools/util/utl \ - unoxml/source/rdf/unordf \ - unoxml/source/service/unoxml \ + basic/util/sb \ + embeddedobj/util/embobj \ + comphelper/util/comphelp \ + configmgr/source/configmgr \ + dbaccess/util/dba \ + filter/source/config/cache/filterconfig1 \ + forms/util/frm \ + framework/util/fwk \ + i18npool/util/i18npool \ + oox/util/oox \ + package/source/xstor/xstor \ + package/util/package2 \ + sax/source/expatwrap/expwrap \ + scripting/source/basprov/basprov \ + scripting/util/scriptframe \ + sfx2/util/sfx \ + sot/util/sot \ + svl/source/fsstor/fsstorage \ + svtools/util/svt \ + sw/util/msword \ + sw/util/sw \ + sw/util/swd \ + sw/util/vbaswobj \ + toolkit/util/tk \ + ucb/source/core/ucb1 \ + ucb/source/ucp/file/ucpfile1 \ + ucb/source/ucp/tdoc/ucptdoc1 \ + unotools/util/utl \ + unoxml/source/rdf/unordf \ + unoxml/source/service/unoxml \ + xmloff/util/xo \ + xmlsecurity/util/$(if $(filter WNT,$(OS)),xsec_xmlsec.windows,xsec_xmlsec) \ )) $(eval $(call gb_CppunitTest_use_configuration,sw_macros_test)) diff --git a/sw/qa/core/data/odt/fdo68983.odt b/sw/qa/core/data/odt/fdo68983.odt Binary files differnew file mode 100644 index 000000000000..01df104407ed --- /dev/null +++ b/sw/qa/core/data/odt/fdo68983.odt diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx index f99885be6713..4e254c0661e9 100644 --- a/sw/qa/core/macros-test.cxx +++ b/sw/qa/core/macros-test.cxx @@ -20,7 +20,11 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/document/MacroExecMode.hpp> +#include <com/sun/star/document/XEmbeddedScripts.hpp> +#include <com/sun/star/script/XLibraryContainer.hpp> +#include <com/sun/star/script/XLibraryContainerPassword.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/drawing/XShape.hpp> @@ -35,6 +39,7 @@ #include <comphelper/processfactory.hxx> #include <basic/sbxdef.hxx> +#include <unotools/tempfile.hxx> #include <doc.hxx> #include "docsh.hxx" @@ -63,6 +68,7 @@ public: //void testStarBasic(); void testVba(); void testFdo55289(); + void testFdo68983(); CPPUNIT_TEST_SUITE(SwMacrosTest); #if !defined(MACOSX) && !defined(WNT) //enable this test if you want to play with star basic macros in unit tests @@ -71,6 +77,7 @@ public: CPPUNIT_TEST(testVba); #endif CPPUNIT_TEST(testFdo55289); + CPPUNIT_TEST(testFdo68983); CPPUNIT_TEST_SUITE_END(); @@ -186,6 +193,47 @@ void SwMacrosTest::testFdo55289() xShapeContent->attach(xEnd); } +void SwMacrosTest::testFdo68983() +{ + const OUString aFileNameBase("StarBasic."); + OUString aFileName; + createFileURL("fdo68983.", "odt", aFileName); + Reference< com::sun::star::lang::XComponent > xComponent = + loadFromDesktop(aFileName, "com.sun.star.text.TextDocument"); + + CPPUNIT_ASSERT_MESSAGE("Failed to load StarBasic.ods", xComponent.is()); + + Reference< frame::XStorable > xDocStorable(xComponent, UNO_QUERY_THROW); + CPPUNIT_ASSERT(xDocStorable.is()); + + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + Sequence<beans::PropertyValue> desc(1); + desc[0].Name = "FilterName"; + desc[0].Value <<= OUString("writer8"); + xDocStorable->storeAsURL(aTempFile.GetURL(), desc); + + Reference<util::XCloseable>(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<document::XEmbeddedScripts> xDocScr(xComponent, UNO_QUERY_THROW); + Reference<script::XStorageBasedLibraryContainer> xStorBasLib(xDocScr->getBasicLibraries()); + Reference<script::XLibraryContainer> xBasLib(xStorBasLib, UNO_QUERY_THROW); + Reference<script::XLibraryContainerPassword> 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<util::XCloseable> xDocCloseable(xComponent, UNO_QUERY_THROW); + xDocCloseable->close(false); +} + + SwMacrosTest::SwMacrosTest() : m_aBaseString("/sw/qa/core/data") { |