summaryrefslogtreecommitdiff
path: root/include/comphelper/unique_disposing_ptr.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'include/comphelper/unique_disposing_ptr.hxx')
-rw-r--r--include/comphelper/unique_disposing_ptr.hxx40
1 files changed, 33 insertions, 7 deletions
diff --git a/include/comphelper/unique_disposing_ptr.hxx b/include/comphelper/unique_disposing_ptr.hxx
index 75be7d6dabec..c986b12e316f 100644
--- a/include/comphelper/unique_disposing_ptr.hxx
+++ b/include/comphelper/unique_disposing_ptr.hxx
@@ -14,6 +14,7 @@
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
#include <vcl/svapp.hxx>
#include <osl/mutex.hxx>
@@ -30,10 +31,10 @@ private:
unique_disposing_ptr(const unique_disposing_ptr&) = delete;
unique_disposing_ptr& operator=(const unique_disposing_ptr&) = delete;
public:
- unique_disposing_ptr( const css::uno::Reference< css::lang::XComponent > &rComponent, T * p = nullptr )
+ unique_disposing_ptr( const css::uno::Reference< css::lang::XComponent > &rComponent, T * p = nullptr, bool bComponent = false)
: m_xItem(p)
{
- m_xTerminateListener = new TerminateListener(rComponent, *this);
+ m_xTerminateListener = new TerminateListener(rComponent, *this, bComponent);
}
virtual void reset(T * p = nullptr)
@@ -66,14 +67,19 @@ public:
reset();
}
private:
- class TerminateListener : public ::cppu::WeakImplHelper< css::frame::XTerminateListener >
+ class TerminateListener : public ::cppu::WeakImplHelper< css::frame::XTerminateListener,
+ css::lang::XServiceInfo>
{
private:
css::uno::Reference< css::lang::XComponent > m_xComponent;
unique_disposing_ptr<T>& m_rItem;
+ bool mbComponentDLL;
public:
TerminateListener(const css::uno::Reference< css::lang::XComponent > &rComponent,
- unique_disposing_ptr<T>& rItem) : m_xComponent(rComponent), m_rItem(rItem)
+ unique_disposing_ptr<T>& rItem, bool bComponentDLL) :
+ m_xComponent(rComponent),
+ m_rItem(rItem),
+ mbComponentDLL(bComponentDLL)
{
if (m_xComponent.is())
{
@@ -97,7 +103,6 @@ private:
}
}
- private:
// XEventListener
virtual void SAL_CALL disposing( const css::lang::EventObject& rEvt )
throw (css::uno::RuntimeException, std::exception) override
@@ -130,6 +135,27 @@ private:
{
disposing(rEvt);
}
+
+ virtual OUString SAL_CALL getImplementationName()
+ throw (css::uno::RuntimeException, std::exception) override
+ {
+ if (mbComponentDLL)
+ return OUString("com.sun.star.comp.ComponentDLLListener");
+ else
+ return OUString("com.sun.star.comp.DisposingTerminateListener");
+ }
+
+ virtual sal_Bool SAL_CALL supportsService(const OUString& /*rName*/)
+ throw (css::uno::RuntimeException, std::exception) override
+ {
+ return false;
+ }
+
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
+ throw (css::uno::RuntimeException, std::exception) override
+ {
+ return css::uno::Sequence<OUString>();
+ }
};
};
@@ -141,8 +167,8 @@ template<class T> class unique_disposing_solar_mutex_reset_ptr
: public unique_disposing_ptr<T>
{
public:
- unique_disposing_solar_mutex_reset_ptr( const css::uno::Reference< css::lang::XComponent > &rComponent, T * p = nullptr )
- : unique_disposing_ptr<T>(rComponent, p)
+ unique_disposing_solar_mutex_reset_ptr( const css::uno::Reference< css::lang::XComponent > &rComponent, T * p = nullptr, bool bComponent = false)
+ : unique_disposing_ptr<T>(rComponent, p, bComponent)
{
}