1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: finalthreadmanager.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _FINALTHREADMANAGER_HXX
31 #define _FINALTHREADMANAGER_HXX
33 #include "sal/config.h"
34 #include "cppuhelper/factory.hxx"
35 #include "cppuhelper/implementationentry.hxx"
36 #include "cppuhelper/implbase3.hxx"
37 #include "com/sun/star/lang/XServiceInfo.hpp"
38 #include "com/sun/star/util/XJobManager.hpp"
39 #include "com/sun/star/frame/XTerminateListener2.hpp"
42 #include <osl/mutex.hxx>
46 class CancelJobsThread
;
47 class TerminateOfficeThread
;
48 class SwPauseThreadStarting
;
50 // service helper namespace
51 namespace comp_FinalThreadManager
{
53 // component and service helper functions:
54 ::rtl::OUString SAL_CALL
_getImplementationName();
55 com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
_getSupportedServiceNames();
56 com::sun::star::uno::Reference
< com::sun::star::uno::XInterface
> SAL_CALL
_create(
57 com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
> const & context
);
59 } // closing service helper namespace
62 class FinalThreadManager
: public ::cppu::WeakImplHelper3
< com::sun::star::lang::XServiceInfo
,
63 com::sun::star::util::XJobManager
,
64 com::sun::star::frame::XTerminateListener2
>
67 explicit FinalThreadManager(com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
> const & context
);
69 // ::com::sun::star::lang::XServiceInfo:
70 virtual ::rtl::OUString SAL_CALL
getImplementationName() throw (com::sun::star::uno::RuntimeException
);
71 virtual ::sal_Bool SAL_CALL
supportsService(const ::rtl::OUString
& ServiceName
) throw (com::sun::star::uno::RuntimeException
);
72 virtual com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException
);
74 // ::com::sun::star::util::XJobManager:
75 virtual void SAL_CALL
registerJob(const com::sun::star::uno::Reference
< com::sun::star::util::XCancellable
> & Job
) throw (com::sun::star::uno::RuntimeException
);
76 virtual void SAL_CALL
releaseJob(const com::sun::star::uno::Reference
< com::sun::star::util::XCancellable
> & Job
) throw (com::sun::star::uno::RuntimeException
);
77 virtual void SAL_CALL
cancelAllJobs() throw (com::sun::star::uno::RuntimeException
);
79 // ::com::sun::star::frame::XTerminateListener2
80 virtual void SAL_CALL
cancelTermination( const ::com::sun::star::lang::EventObject
& Event
) throw (::com::sun::star::uno::RuntimeException
);
82 // ::com::sun::star::frame::XTerminateListener (inherited via com::sun::star::frame::XTerminateListener2)
83 virtual void SAL_CALL
queryTermination( const ::com::sun::star::lang::EventObject
& Event
) throw (::com::sun::star::frame::TerminationVetoException
, ::com::sun::star::uno::RuntimeException
);
84 virtual void SAL_CALL
notifyTermination( const ::com::sun::star::lang::EventObject
& Event
) throw (::com::sun::star::uno::RuntimeException
);
86 // ::com::sun:star::lang::XEventListener (inherited via com::sun::star::frame::XTerminateListener)
87 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw (::com::sun::star::uno::RuntimeException
);
90 FinalThreadManager(FinalThreadManager
&); // not defined
91 void operator =(FinalThreadManager
&); // not defined
93 virtual ~FinalThreadManager();
95 void registerAsListenerAtDesktop();
97 com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
> m_xContext
;
101 std::list
< com::sun::star::uno::Reference
< com::sun::star::util::XCancellable
> > maThreads
;
102 CancelJobsThread
* mpCancelJobsThread
;
103 TerminateOfficeThread
* mpTerminateOfficeThread
;
104 SwPauseThreadStarting
* mpPauseThreadStarting
;
106 bool mbRegisteredAtDesktop
;