diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-08-24 12:46:00 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2015-09-10 04:14:45 +0200 |
commit | 85f42858043b07eb52b32cc42fe8c22a8333a21e (patch) | |
tree | 44bbb12395e2dd8876c9c95bfd802f4a348aead4 /oox | |
parent | 3187eeab10df77a6c0dd6397be993a68276d7141 (diff) |
get correct vba project name
Change-Id: I48efd62ca1df00b8a0cbecb01b394814ca40c2e9
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/ole/vbaexport.cxx | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/oox/source/ole/vbaexport.cxx b/oox/source/ole/vbaexport.cxx index dbcc2560c48c..feecd37d95b7 100644 --- a/oox/source/ole/vbaexport.cxx +++ b/oox/source/ole/vbaexport.cxx @@ -13,6 +13,7 @@ #include <com/sun/star/script/XLibraryContainer.hpp> #include <com/sun/star/script/vba/XVBAModuleInfo.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> #include <com/sun/star/frame/XModel.hpp> #include <oox/helper/binaryoutputstream.hxx> @@ -313,8 +314,6 @@ void VBACompression::write() VbaExport::VbaExport(css::uno::Reference<css::frame::XModel> xModel): mxModel(xModel) { - // TODO: how do we get the correct project name - maProjectName = "VBAProject"; } namespace { @@ -642,20 +641,28 @@ void VbaExport::exportVBA() aStorage->Commit(); } +css::uno::Reference<css::script::XLibraryContainer> VbaExport::getLibraryContainer() +{ + oox::PropertySet aDocProp(mxModel); + css::uno::Reference<css::script::XLibraryContainer> xLibContainer(aDocProp.getAnyProperty(oox::PROP_BasicLibraries), css::uno::UNO_QUERY); + + return xLibContainer; +} + css::uno::Reference<css::container::XNameContainer> VbaExport::getBasicLibrary() { css::uno::Reference<css::container::XNameContainer> xLibrary; try { - oox::PropertySet aDocProp(mxModel); - css::uno::Reference<css::script::XLibraryContainer> xLibContainer(aDocProp.getAnyProperty(oox::PROP_BasicLibraries), css::uno::UNO_QUERY_THROW); + css::uno::Reference<css::script::XLibraryContainer> xLibContainer = getLibraryContainer(); css::uno::Sequence<OUString> aElementNames = xLibContainer->getElementNames(); sal_Int32 n = aElementNames.getLength(); for (sal_Int32 i = 0; i < n; ++i) { SAL_DEBUG(aElementNames[i]); } - xLibrary.set( xLibContainer->getByName(maProjectName), css::uno::UNO_QUERY_THROW ); + OUString aProjectName = getProjectName(); + xLibrary.set( xLibContainer->getByName(aProjectName), css::uno::UNO_QUERY_THROW ); } catch(...) { @@ -664,4 +671,28 @@ css::uno::Reference<css::container::XNameContainer> VbaExport::getBasicLibrary() return xLibrary; } +bool VbaExport::containsVBAProject() +{ + css::uno::Reference<css::script::XLibraryContainer> xLibContainer = getLibraryContainer(); + if (!xLibContainer.is()) + return false; + + css::uno::Reference<css::script::vba::XVBACompatibility> xVbaCompatibility (xLibContainer, css::uno::UNO_QUERY); + if (!xVbaCompatibility.is()) + return false; + + bool bVBACompatibilty = xVbaCompatibility->getVBACompatibilityMode(); + + return bVBACompatibilty; +} + +OUString VbaExport::getProjectName() +{ + css::uno::Reference<css::script::vba::XVBACompatibility> xVbaCompatibility(getLibraryContainer(), css::uno::UNO_QUERY); + if (xVbaCompatibility.is()) + return xVbaCompatibility->getProjectName(); + + return OUString(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |