From ed2a220f5401b0cc315c43e5da04362e1095a173 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Mon, 9 Aug 2010 15:01:40 +0200 Subject: [PATCH 1/4] oooimprovement6: #i100159# catching the OnLogRotate thread in a clean fashion --- .../source/oooimprovement/onlogrotate_job.cxx | 43 ++++++++++++++++--- 1 file 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 +#include +#include #include #include #include +#include +#include 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 sf); virtual void SAL_CALL run(); - void disposing(); + OnLogRotateThread* disposing(); + private: Reference 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 + { + public: + OnLogRotateThreadWatcher(Reference 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 m_Thread; + }; } namespace oooimprovement @@ -163,9 +194,11 @@ namespace oooimprovement const Reference& listener) throw(RuntimeException) { - OnLogRotateThread* thread = new OnLogRotateThread(m_ServiceFactory); - thread->create(); - + Reference xDesktop( + m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.frame.Desktop")), + UNO_QUERY); + if(xDesktop.is()) + xDesktop->addTerminateListener(Reference(new OnLogRotateThreadWatcher(m_ServiceFactory))); Any result; listener->jobFinished(Reference(this), result); } From bac4d759bdcf17fd4438024367ca2bc2bc982011 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Wed, 11 Aug 2010 08:29:50 +0200 Subject: [PATCH 2/4] oooimprovement6: #i98561# clicking on show data closes the modal dialog --- cui/source/options/optimprove2.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cui/source/options/optimprove2.cxx b/cui/source/options/optimprove2.cxx index 29ef718a6c74..074897c3df29 100644 --- a/cui/source/options/optimprove2.cxx +++ b/cui/source/options/optimprove2.cxx @@ -153,7 +153,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(GetParent())->EndDialog( RET_CANCEL ); return 1; + } } return 0; From 00b6e5da07f6fb27d244a68832b39bafbaccea45 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Wed, 11 Aug 2010 09:47:56 +0200 Subject: [PATCH 3/4] oooimprovement6: #i97340# disable show data button when no file exists --- cui/source/options/optimprove2.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cui/source/options/optimprove2.cxx b/cui/source/options/optimprove2.cxx index 074897c3df29..841fbc1d3fb1 100644 --- a/cui/source/options/optimprove2.cxx +++ b/cui/source/options/optimprove2.cxx @@ -52,6 +52,7 @@ #include #include #include +#include #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 SvxEmptyPage ---------------------------------------------------- SvxEmptyPage::SvxEmptyPage( Window* pParent ) : @@ -262,11 +275,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); } } From 43ace9c1b12b78932d9de462a2710cb71944292f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Sat, 4 Sep 2010 17:28:24 +0100 Subject: [PATCH 4/4] cmcfixes78: #i111733# fflush on stdin --- xmlsecurity/tools/demo/util2.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xmlsecurity/tools/demo/util2.cxx b/xmlsecurity/tools/demo/util2.cxx index 955cb94a0474..0ec576d8d3f8 100644 --- a/xmlsecurity/tools/demo/util2.cxx +++ b/xmlsecurity/tools/demo/util2.cxx @@ -384,7 +384,7 @@ void QueryPrintSignatureDetails( const SignatureInformations& SignatureInformati { char cShowDetails; fprintf( stdout, "\nDisplay details (y/n) [y]?" ); - fflush(stdin); + fflush( stdout ); fscanf( stdin, "%c", &cShowDetails); if ( cShowDetails == 'y' ) { @@ -409,7 +409,7 @@ int QuerySelectNumber( int nMin, int nMax ) do { fprintf( stdout, "\nSelect <%d-%d>:", nMin, nMax ) ; - fflush(stdin); + fflush( stdout ); fscanf( stdin, "%d", &sel ) ; } while( ( sel < nMin ) || ( sel > nMax ) ); @@ -420,7 +420,7 @@ long QueryVerifySignature() { char answer; fprintf( stdout, "\nFound a signature - verify this one (y/n) [y]?" ); - fflush(stdin); + fflush( stdout ); fscanf( stdin, "%c", &answer); return (answer == 'n')?0:1; }