summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorHans-Joachim Lankenau <hjs@openoffice.org>2010-09-17 15:39:00 +0200
committerHans-Joachim Lankenau <hjs@openoffice.org>2010-09-17 15:39:00 +0200
commit05e178629a416b8c087099c2840ae7c2bffa2733 (patch)
tree1dd093ff5f1e32c3437cc4724f38e98302efb99b /extensions
parent88feb4170fa4b12287a81123f3df0bb3119bba80 (diff)
parent00b6e5da07f6fb27d244a68832b39bafbaccea45 (diff)
CWS-TOOLING: integrate CWS oooimprovement6
Notes
Notes: split repo tag: components_ooo/DEV300_m88
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/oooimprovement/onlogrotate_job.cxx43
1 files changed, 38 insertions, 5 deletions
diff --git a/extensions/source/oooimprovement/onlogrotate_job.cxx b/extensions/source/oooimprovement/onlogrotate_job.cxx
index a92044b87d7e..3007ada42aba 100644
--- a/extensions/source/oooimprovement/onlogrotate_job.cxx
+++ b/extensions/source/oooimprovement/onlogrotate_job.cxx
@@ -35,15 +35,21 @@
#include "soapsender.hxx"
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/XTerminateListener.hpp>
#include <osl/mutex.hxx>
#include <osl/thread.hxx>
#include <osl/time.h>
+#include <cppuhelper/implbase1.hxx>
+#include <memory>
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::uno;
+using ::com::sun::star::frame::XTerminateListener;
+using ::com::sun::star::frame::XDesktop;
using ::com::sun::star::ucb::XSimpleFileAccess;
using ::rtl::OUString;
using ::std::vector;
@@ -102,7 +108,8 @@ namespace
public:
OnLogRotateThread(Reference<XMultiServiceFactory> sf);
virtual void SAL_CALL run();
- void disposing();
+ OnLogRotateThread* disposing();
+
private:
Reference<XMultiServiceFactory> m_ServiceFactory;
::osl::Mutex m_ServiceFactoryMutex;
@@ -135,11 +142,35 @@ namespace
}
}
- void OnLogRotateThread::disposing()
+ OnLogRotateThread* OnLogRotateThread::disposing()
{
::osl::Guard< ::osl::Mutex> service_factory_guard(m_ServiceFactoryMutex);
m_ServiceFactory.clear();
+ return this;
}
+
+ class OnLogRotateThreadWatcher : public ::cppu::WeakImplHelper1<XTerminateListener>
+ {
+ public:
+ OnLogRotateThreadWatcher(Reference<XMultiServiceFactory> sf)
+ : m_Thread(new OnLogRotateThread(sf))
+ {
+ m_Thread->create();
+ }
+ virtual ~OnLogRotateThreadWatcher()
+ { m_Thread->disposing()->terminate(); };
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination(const EventObject&) throw(RuntimeException)
+ { };
+ virtual void SAL_CALL notifyTermination(const EventObject&) throw(RuntimeException)
+ { m_Thread->disposing()->terminate(); };
+ // XEventListener
+ virtual void SAL_CALL disposing(const EventObject&) throw(RuntimeException)
+ { m_Thread->disposing()->terminate(); };
+ private:
+ ::std::auto_ptr<OnLogRotateThread> m_Thread;
+ };
}
namespace oooimprovement
@@ -163,9 +194,11 @@ namespace oooimprovement
const Reference<XJobListener>& listener)
throw(RuntimeException)
{
- OnLogRotateThread* thread = new OnLogRotateThread(m_ServiceFactory);
- thread->create();
-
+ Reference<XDesktop> xDesktop(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.frame.Desktop")),
+ UNO_QUERY);
+ if(xDesktop.is())
+ xDesktop->addTerminateListener(Reference<XTerminateListener>(new OnLogRotateThreadWatcher(m_ServiceFactory)));
Any result;
listener->jobFinished(Reference<XAsyncJob>(this), result);
}