diff options
author | Hans-Joachim Lankenau <hjs@openoffice.org> | 2010-09-17 15:39:00 +0200 |
---|---|---|
committer | Hans-Joachim Lankenau <hjs@openoffice.org> | 2010-09-17 15:39:00 +0200 |
commit | 09cfcedc6eae7af61e047a956d672702f1313c6d (patch) | |
tree | 382433e5df0aa6f8fb2afef5688c66c9d3acc962 | |
parent | 64a24055319d82d1f5453d9760f661452a2d79b0 (diff) | |
parent | f250c783207d3c2f1d0515ebd1b1b21a7639aca7 (diff) |
CWS-TOOLING: integrate CWS oooimprovement6ooo/DEV300_m88
-rw-r--r-- | cui/source/options/optimprove2.cxx | 18 | ||||
-rw-r--r-- | extensions/source/oooimprovement/onlogrotate_job.cxx | 43 |
2 files changed, 56 insertions, 5 deletions
diff --git a/cui/source/options/optimprove2.cxx b/cui/source/options/optimprove2.cxx index 562280426..9a49fa2e6 100644 --- a/cui/source/options/optimprove2.cxx +++ b/cui/source/options/optimprove2.cxx @@ -52,6 +52,7 @@ #include <comphelper/synchronousdispatch.hxx> #include <comphelper/uieventslogger.hxx> #include <tools/testtoolloader.hxx> +#include <osl/file.hxx> #define C2S(s) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) @@ -61,6 +62,18 @@ namespace uno = ::com::sun::star::uno; namespace util = ::com::sun::star::util; using namespace com::sun::star::system; + +namespace +{ + bool lcl_doesLogfileExist(const ::rtl::OUString& sLogPath) + { + ::rtl::OUString sLogFile( sLogPath ); + sLogFile += C2S("/Current.csv"); + ::osl::File aLogFile(sLogFile); + return aLogFile.open(osl_File_OpenFlag_Read) == ::osl::FileBase::E_None; + } +} + // class SvxImprovementOptionsPage --------------------------------------- SvxImprovementOptionsPage::SvxImprovementOptionsPage( Window* pParent, const SfxItemSet& rSet ) : @@ -143,7 +156,10 @@ IMPL_LINK( SvxImprovementOptionsPage, HandleShowData, PushButton*, EMPTYARG ) uno::Reference< lang::XComponent > xDoc = ::comphelper::SynchronousDispatch::dispatch( xDesktop, sLogFile, C2S("_default"), 0, aArgs ); if ( xDoc.is() ) + { + dynamic_cast<Dialog*>(GetParent())->EndDialog( RET_CANCEL ); return 1; + } } return 0; @@ -244,11 +260,13 @@ void SvxImprovementOptionsPage::Reset( const SfxItemSet& /*rSet*/ ) if ( xSubst.is() ) sPath = xSubst->substituteVariables( sPath, sal_False ); m_sLogPath = sPath; + m_aShowDataPB.Enable(lcl_doesLogfileExist(m_sLogPath)); } } } catch( uno::Exception& ) { + m_aShowDataPB.Enable(false); } } diff --git a/extensions/source/oooimprovement/onlogrotate_job.cxx b/extensions/source/oooimprovement/onlogrotate_job.cxx index 9ee771aa9..fa497f62f 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); } |