From 5ee6862ee420f13133ade382d7ef2be319414d40 Mon Sep 17 00:00:00 2001 From: Tamas Bunth Date: Thu, 6 Jul 2017 10:46:48 +0200 Subject: Create vba library if it did not exist before MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add basicLibraries to the library container in the ensure function. It is needed in case of an xlsm file, because the VBAProject library was not added by the filter. Change-Id: I13f78384b9b1bbff1d9d5b1cd36d5a3b878f63e6 Reviewed-on: https://gerrit.libreoffice.org/39622 Tested-by: Jenkins Reviewed-by: Tamás Bunth --- vbahelper/source/vbahelper/vbaeventshelperbase.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx index 87b6fac6df38..800fa7231f8e 100644 --- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx +++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -295,6 +296,14 @@ void VbaEventsHelperBase::ensureVBALibrary() uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW ); uno::Reference< container::XNameAccess > xBasicLibs( xModelProps->getPropertyValue( "BasicLibraries" ), uno::UNO_QUERY_THROW ); + + if(!xBasicLibs->hasByName(maLibraryName) ) + { + uno::Reference< script::XLibraryContainer > xLibContainer( + xModelProps->getPropertyValue("BasicLibraries"), uno::UNO_QUERY_THROW); + xLibContainer->createLibrary(maLibraryName); + } + mxModuleInfos.set( xBasicLibs->getByName( maLibraryName ), uno::UNO_QUERY_THROW ); // listen to changes in the VBA source code uno::Reference< util::XChangesNotifier > xChangesNotifier( mxModuleInfos, uno::UNO_QUERY_THROW ); -- cgit