summaryrefslogtreecommitdiff
path: root/vbahelper
diff options
context:
space:
mode:
authorTamas Bunth <tamas.bunth@collabora.co.uk>2017-07-06 10:46:48 +0200
committerTamás Bunth <btomi96@gmail.com>2017-07-06 22:37:12 +0200
commit5ee6862ee420f13133ade382d7ef2be319414d40 (patch)
treedc255b1cf96f9e8f99d77c3a92b488af87c938db /vbahelper
parent388041695d9626970b0d4dce89241c849eeffd0e (diff)
Create vba library if it did not exist before
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 <ci@libreoffice.org> Reviewed-by: Tamás Bunth <btomi96@gmail.com>
Diffstat (limited to 'vbahelper')
-rw-r--r--vbahelper/source/vbahelper/vbaeventshelperbase.cxx9
1 files changed, 9 insertions, 0 deletions
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 <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/script/ModuleType.hpp>
#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
#include <com/sun/star/util/XChangesNotifier.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <filter/msfilter/msvbahelper.hxx>
@@ -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 );