diff options
Diffstat (limited to 'filter/source/config/cache/typedetection.hxx')
-rw-r--r-- | filter/source/config/cache/typedetection.hxx | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/filter/source/config/cache/typedetection.hxx b/filter/source/config/cache/typedetection.hxx index 18185134af5a..830badc54f63 100644 --- a/filter/source/config/cache/typedetection.hxx +++ b/filter/source/config/cache/typedetection.hxx @@ -21,14 +21,16 @@ #include "basecontainer.hxx" #include <com/sun/star/document/XTypeDetection.hpp> +#include <com/sun/star/frame/XTerminateListener.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <unotools/mediadescriptor.hxx> +#include <cppuhelper/compbase.hxx> #include <cppuhelper/implbase.hxx> - namespace filter{ namespace config { +class TerminateDetection; /** @short implements the service <type scope="com.sun.star.document">TypeDetection</type>. */ @@ -39,6 +41,8 @@ class TypeDetection : public ::cppu::ImplInheritanceHelper< BaseContainer // native interface css::uno::Reference< css::uno::XComponentContext > m_xContext; + rtl::Reference<TerminateDetection> m_xTerminateListener; + bool m_bCancel; public: @@ -53,6 +57,11 @@ public: */ explicit TypeDetection(const css::uno::Reference< css::uno::XComponentContext >& rxContext); + void cancel() + { + m_bCancel = true; + } + /** @short standard dtor. */ @@ -362,6 +371,36 @@ public: static css::uno::Reference< css::uno::XInterface > impl_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR); }; +class TerminateDetection : public cppu::WeakComponentImplHelper<css::frame::XTerminateListener> +{ +private: + osl::Mutex m_aLock; + TypeDetection* m_pTypeDetection; + +public: + + using cppu::WeakComponentImplHelperBase::disposing; + virtual void SAL_CALL disposing(const css::lang::EventObject&) override + { + } + + // XTerminateListener + virtual void SAL_CALL queryTermination(const css::lang::EventObject&) override + { + m_pTypeDetection->cancel(); + } + + virtual void SAL_CALL notifyTermination(const css::lang::EventObject&) override + { + } + + TerminateDetection(TypeDetection* pTypeDetection) + : cppu::WeakComponentImplHelper<css::frame::XTerminateListener>(m_aLock) + , m_pTypeDetection(pTypeDetection) + { + } +}; + }} #endif // INCLUDED_FILTER_SOURCE_CONFIG_CACHE_TYPEDETECTION_HXX |