10 #ifndef INCLUDED_COMPHELPER_UNIQUE_DISPOSING_PTR_HXX
11 #define INCLUDED_COMPHELPER_UNIQUE_DISPOSING_PTR_HXX
16 #include <com/sun/star/lang/XComponent.hpp>
17 #include <com/sun/star/frame/XDesktop.hpp>
18 #include <com/sun/star/lang/XServiceInfo.hpp>
29 std::unique_ptr<T, o3tl::default_delete<T>>
m_xItem;
35 unique_disposing_ptr(
const css::uno::Reference< css::lang::XComponent > &rComponent, T * p =
nullptr,
bool bComponent =
false)
41 virtual void reset(T * p =
nullptr)
61 operator bool ()
const
63 return static_cast< bool >(
m_xItem);
71 class TerminateListener final :
public ::cppu::WeakImplHelper< css::frame::XTerminateListener,
72 css::lang::XServiceInfo>
81 m_xComponent(rComponent),
83 mbComponentDLL(bComponentDLL)
85 if (m_xComponent.is())
87 css::uno::Reference< css::frame::XDesktop> xDesktop(m_xComponent, css::uno::UNO_QUERY);
89 xDesktop->addTerminateListener(
this);
91 m_xComponent->addEventListener(
this);
97 if ( m_xComponent.is() )
99 css::uno::Reference< css::frame::XDesktop> xDesktop(m_xComponent, css::uno::UNO_QUERY);
101 xDesktop->removeTerminateListener(
this);
103 m_xComponent->removeEventListener(
this);
108 virtual void SAL_CALL
disposing(
const css::lang::EventObject& rEvt )
override
112 if (shutDown && m_xComponent.is())
114 css::uno::Reference< css::frame::XDesktop> xDesktop(m_xComponent, css::uno::UNO_QUERY);
116 xDesktop->removeTerminateListener(
this);
118 m_xComponent->removeEventListener(
this);
119 m_xComponent.clear();
139 return "com.sun.star.comp.ComponentDLLListener";
141 return "com.sun.star.comp.DisposingTerminateListener";
151 return css::uno::Sequence<OUString>();
169 virtual void reset(T * p =
nullptr)
override
unique_disposing_ptr & operator=(const unique_disposing_ptr &)=delete
TerminateListener(const css::uno::Reference< css::lang::XComponent > &rComponent, unique_disposing_ptr< T > &rItem, bool bComponentDLL)
virtual ~unique_disposing_ptr() COVERITY_NOEXCEPT_FALSE
virtual void SAL_CALL disposing(const css::lang::EventObject &rEvt) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual ~TerminateListener() override
unique_disposing_ptr(const unique_disposing_ptr &)=delete
virtual sal_Bool SAL_CALL supportsService(const OUString &) override
css::uno::Reference< css::lang::XComponent > m_xComponent
std::unique_ptr< T, o3tl::default_delete< T > > m_xItem
virtual void reset(T *p=nullptr) override
css::uno::Reference< css::frame::XTerminateListener > m_xTerminateListener
unique_disposing_solar_mutex_reset_ptr(const css::uno::Reference< css::lang::XComponent > &rComponent, T *p=nullptr, bool bComponent=false)
virtual void SAL_CALL queryTermination(const css::lang::EventObject &) override
bool const mbComponentDLL
virtual void SAL_CALL notifyTermination(const css::lang::EventObject &rEvt) override
unique_disposing_ptr(const css::uno::Reference< css::lang::XComponent > &rComponent, T *p=nullptr, bool bComponent=false)
virtual void reset(T *p=nullptr)
static SolarMutex * get()
Help components to get the SolarMutex easily.
unique_disposing_ptr< T > & m_rItem
virtual ~unique_disposing_solar_mutex_reset_ptr() override
virtual OUString SAL_CALL getImplementationName() override