diff options
author | Henry Castro <hcastro@collabora.com> | 2018-05-17 11:12:56 -0400 |
---|---|---|
committer | Henry Castro <hcastro@collabora.com> | 2018-05-28 00:03:40 +0200 |
commit | 5f1ce0a77c63df597fba9d4cbd45be3a266343c3 (patch) | |
tree | 53c9322c16f62283a7cb842c1d6ee569beefd0a7 /sc/source/ui/docshell | |
parent | 539e8f1d80d497bd8d7ee031cb5772e49021b79c (diff) |
sc: release XTransferable2 when used with VBA compatibility helpers
Copy, Cut, PasteSpecial and Insert is used by Range excel object,
so after finishing executing the VBA script ensure to release XTransferable2
interface
Change-Id: I967a7ba1a1d101282f7a1b9d4b2e2ac3004f1c07
Reviewed-on: https://gerrit.libreoffice.org/54497
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'sc/source/ui/docshell')
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index b814ddceb6b9..d2ae9a945c18 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -48,7 +48,10 @@ #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/document/UpdateDocMode.hpp> #include <com/sun/star/script/vba/VBAEventId.hpp> +#include <com/sun/star/script/vba/VBAScriptEventId.hpp> #include <com/sun/star/script/vba/XVBAEventProcessor.hpp> +#include <com/sun/star/script/vba/XVBAScriptListener.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> #include <com/sun/star/sheet/XSpreadsheetView.hpp> #include <com/sun/star/task/XJob.hpp> #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp> @@ -441,6 +444,32 @@ public: bool get_active() const { return m_xWarningOnBox->get_active(); } }; + +class VBAScriptListener : public ::cppu::WeakImplHelper< css::script::vba::XVBAScriptListener > +{ +private: + ScDocShell* m_pDocSh; +public: + VBAScriptListener(ScDocShell* pDocSh) : m_pDocSh(pDocSh) + { + } + + // XVBAScriptListener + virtual void SAL_CALL notifyVBAScriptEvent( const ::css::script::vba::VBAScriptEvent& aEvent ) override + { + if (aEvent.Identifier == script::vba::VBAScriptEventId::SCRIPT_STOPPED && + m_pDocSh->GetClipData().is()) + { + m_pDocSh->SetClipData(uno::Reference<datatransfer::XTransferable2>()); + } + } + + // XEventListener + virtual void SAL_CALL disposing( const ::css::lang::EventObject& /*Source*/ ) override + { + } +}; + } bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css::embed::XStorage >& xStor ) @@ -688,6 +717,7 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) else if ( dynamic_cast<const SfxEventHint*>(&rHint) ) { SfxEventHintId nEventId = static_cast<const SfxEventHint*>(&rHint)->GetEventId(); + switch ( nEventId ) { case SfxEventHintId::LoadFinished: @@ -717,6 +747,15 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) break; case SfxEventHintId::ViewCreated: { + #if HAVE_FEATURE_SCRIPTING + uno::Reference<script::vba::XVBACompatibility> xVBACompat(GetBasicContainer(), uno::UNO_QUERY); + if ( !m_xVBAListener.is() && xVBACompat.is() ) + { + m_xVBAListener.set(new VBAScriptListener(this)); + xVBACompat->addVBAScriptListener(m_xVBAListener); + } +#endif + #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT if ( IsDocShared() && !SC_MOD()->IsInSharedDocLoading() ) { @@ -1020,6 +1059,15 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) } else if (rHint.GetId() == SfxHintId::Deinitializing) { + +#if HAVE_FEATURE_SCRIPTING + uno::Reference<script::vba::XVBACompatibility> xVBACompat(GetBasicContainer(), uno::UNO_QUERY); + if (m_xVBAListener.is() && xVBACompat.is()) + { + xVBACompat->removeVBAScriptListener(m_xVBAListener); + } +#endif + if (aDocument.IsClipboardSource()) { // Notes copied to the clipboard have a raw SdrCaptionObj pointer |