xref: /aoo41x/main/sfx2/source/appl/shutdownicon.hxx (revision 143238c7)
1353d8f4dSAndrew Rist /**************************************************************
2353d8f4dSAndrew Rist  *
3353d8f4dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4353d8f4dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5353d8f4dSAndrew Rist  * distributed with this work for additional information
6353d8f4dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7353d8f4dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8353d8f4dSAndrew Rist  * "License"); you may not use this file except in compliance
9353d8f4dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10353d8f4dSAndrew Rist  *
11353d8f4dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12353d8f4dSAndrew Rist  *
13353d8f4dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14353d8f4dSAndrew Rist  * software distributed under the License is distributed on an
15353d8f4dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16353d8f4dSAndrew Rist  * KIND, either express or implied.  See the License for the
17353d8f4dSAndrew Rist  * specific language governing permissions and limitations
18353d8f4dSAndrew Rist  * under the License.
19353d8f4dSAndrew Rist  *
20353d8f4dSAndrew Rist  *************************************************************/
21353d8f4dSAndrew Rist 
22cdf0e10cSrcweir 
23cdf0e10cSrcweir #ifndef __SHUTDOWNICON_HXX__
24cdf0e10cSrcweir #define __SHUTDOWNICON_HXX__
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/frame/XTerminateListener.hpp>
27cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
28cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
29cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
31cdf0e10cSrcweir #include <com/sun/star/lang/XEventListener.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
34cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
35cdf0e10cSrcweir #include <com/sun/star/beans/XFastPropertySet.hpp>
36cdf0e10cSrcweir #ifndef _RTL_STRING_HXX
37cdf0e10cSrcweir #include <rtl/string.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _RTL_USTRING_HXX
40cdf0e10cSrcweir #include <rtl/ustring.hxx>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include <osl/mutex.hxx>
43cdf0e10cSrcweir #include <osl/module.hxx>
44cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
45cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
46cdf0e10cSrcweir #include <sfx2/dllapi.h>
47*143238c7SAriel Constenla-Haile #include <tools/link.hxx>
48cdf0e10cSrcweir 
49*143238c7SAriel Constenla-Haile struct AsyncDesktopTerminationData;
50cdf0e10cSrcweir class ResMgr;
51cdf0e10cSrcweir namespace sfx2
52cdf0e10cSrcweir {
53cdf0e10cSrcweir     class FileDialogHelper;
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
56cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper4<
57cdf0e10cSrcweir 	::com::sun::star::lang::XInitialization,
58cdf0e10cSrcweir 	::com::sun::star::frame::XTerminateListener,
59cdf0e10cSrcweir 	::com::sun::star::lang::XServiceInfo,
60cdf0e10cSrcweir     ::com::sun::star::beans::XFastPropertySet > ShutdownIconServiceBase;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #if defined(USE_APP_SHORTCUTS)
63cdf0e10cSrcweir #define WRITER_URL      "private:factory/swriter"
64cdf0e10cSrcweir #define CALC_URL        "private:factory/scalc"
65cdf0e10cSrcweir #define IMPRESS_URL     "private:factory/simpress"
66cdf0e10cSrcweir #define IMPRESS_WIZARD_URL     "private:factory/simpress?slot=6686"
67cdf0e10cSrcweir #define DRAW_URL        "private:factory/sdraw"
68cdf0e10cSrcweir #define MATH_URL        "private:factory/smath"
69cdf0e10cSrcweir #define BASE_URL        "private:factory/sdatabase?Interactive"
70cdf0e10cSrcweir #define STARTMODULE_URL ".uno:ShowStartModule"
71cdf0e10cSrcweir #endif
72cdf0e10cSrcweir 
73cdf0e10cSrcweir class SFX2_DLLPUBLIC ShutdownIcon :	public ShutdownIconServiceBase
74cdf0e10cSrcweir {
75cdf0e10cSrcweir         ::osl::Mutex            m_aMutex;
76cdf0e10cSrcweir         bool                    m_bVeto;
77cdf0e10cSrcweir         bool                    m_bListenForTermination;
78cdf0e10cSrcweir         bool                    m_bSystemDialogs;
79cdf0e10cSrcweir         ResMgr*                 m_pResMgr;
80cdf0e10cSrcweir         sfx2::FileDialogHelper* m_pFileDlg;
81cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir         static ShutdownIcon *pShutdownIcon; // one instance
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 		oslGenericFunction m_pInitSystray;
86cdf0e10cSrcweir 		oslGenericFunction m_pDeInitSystray;
87cdf0e10cSrcweir 		::osl::Module  *m_pPlugin;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 		bool m_bInitialized;
90cdf0e10cSrcweir 		void initSystray();
91cdf0e10cSrcweir 		void deInitSystray();
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 		static bool LoadModule( osl::Module **pModule,
94cdf0e10cSrcweir 								oslGenericFunction *pInit,
95cdf0e10cSrcweir 								oslGenericFunction *pDeInit );
96cdf0e10cSrcweir 		static void EnterModalMode();
97cdf0e10cSrcweir 		static void LeaveModalMode();
98cdf0e10cSrcweir 		static rtl::OUString getShortcutName();
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 		friend class SfxNotificationListener_Impl;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	public:
103cdf0e10cSrcweir 		ShutdownIcon( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > aSMgr );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 		virtual ~ShutdownIcon();
106cdf0e10cSrcweir 
107*143238c7SAriel Constenla-Haile         DECL_STATIC_LINK( ShutdownIcon, AsyncDesktopTermination, AsyncDesktopTerminationData* );
108*143238c7SAriel Constenla-Haile 
109cdf0e10cSrcweir         SFX_DECL_XSERVICEINFO
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 		static ShutdownIcon* getInstance();
112cdf0e10cSrcweir 		static ShutdownIcon* createInstance();
113cdf0e10cSrcweir 
114cdf0e10cSrcweir         static void terminateDesktop();
115cdf0e10cSrcweir 		static void addTerminateListener();
116cdf0e10cSrcweir 
117cdf0e10cSrcweir         static void FileOpen();
118cdf0e10cSrcweir         static void OpenURL( const ::rtl::OUString& aURL, const ::rtl::OUString& rTarget, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& =
119cdf0e10cSrcweir 			::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >( 0 ) );
120cdf0e10cSrcweir         static void FromTemplate();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir         static void SetAutostart( bool bActivate );
123cdf0e10cSrcweir         static bool GetAutostart();
124cdf0e10cSrcweir 		static bool bModalMode;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		void init() throw( ::com::sun::star::uno::Exception );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 		static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >
129cdf0e10cSrcweir 					GetWrapperFactory( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSMgr );
130cdf0e10cSrcweir 		static ::rtl::OUString  GetImplementationName_static();
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         ::rtl::OUString GetResString( int id );
133cdf0e10cSrcweir         ::rtl::OUString GetUrlDescription( const ::rtl::OUString& aUrl );
134cdf0e10cSrcweir 
SetVeto(bool bVeto)135cdf0e10cSrcweir         void SetVeto( bool bVeto )  { m_bVeto = bVeto;}
GetVeto()136cdf0e10cSrcweir         bool GetVeto()              { return m_bVeto; }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         void                    StartFileDialog();
GetFileDialog() const139cdf0e10cSrcweir         sfx2::FileDialogHelper* GetFileDialog() const { return m_pFileDlg; }
140cdf0e10cSrcweir         static long DialogClosedHdl_Impl( ShutdownIcon*, sfx2::FileDialogHelper* );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir         static bool IsQuickstarterInstalled();
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 		// Component Helper - force override
145cdf0e10cSrcweir 		virtual void SAL_CALL disposing();
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 		// XEventListener
148cdf0e10cSrcweir 		virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
149cdf0e10cSrcweir 			throw(::com::sun::star::uno::RuntimeException);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 		// XTerminateListener
152cdf0e10cSrcweir 		virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent )
153cdf0e10cSrcweir 			throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
154cdf0e10cSrcweir 		virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
155cdf0e10cSrcweir 			throw(::com::sun::star::uno::RuntimeException);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		// XInitialization
158cdf0e10cSrcweir 		virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
159cdf0e10cSrcweir 			throw( ::com::sun::star::uno::Exception );
160cdf0e10cSrcweir 
161cdf0e10cSrcweir         // XFastPropertySet
162cdf0e10cSrcweir         virtual void SAL_CALL setFastPropertyValue(       ::sal_Int32                  nHandle,
163cdf0e10cSrcweir                                                     const ::com::sun::star::uno::Any& aValue )
164cdf0e10cSrcweir             throw (::com::sun::star::beans::UnknownPropertyException,
165cdf0e10cSrcweir                     ::com::sun::star::beans::PropertyVetoException,
166cdf0e10cSrcweir                     ::com::sun::star::lang::IllegalArgumentException,
167cdf0e10cSrcweir                     ::com::sun::star::lang::WrappedTargetException,
168cdf0e10cSrcweir                     ::com::sun::star::uno::RuntimeException);
169cdf0e10cSrcweir         virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle )
170cdf0e10cSrcweir             throw (::com::sun::star::beans::UnknownPropertyException,
171cdf0e10cSrcweir                     ::com::sun::star::lang::WrappedTargetException,
172cdf0e10cSrcweir                     ::com::sun::star::uno::RuntimeException);
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > m_xDesktop;
175cdf0e10cSrcweir 
176cdf0e10cSrcweir #ifdef WNT
177cdf0e10cSrcweir 		static void EnableAutostartW32( const rtl::OUString &aShortcutName );
178cdf0e10cSrcweir 		static rtl::OUString GetAutostartFolderNameW32();
179cdf0e10cSrcweir #endif
180cdf0e10cSrcweir #ifdef OS2
181cdf0e10cSrcweir 	        static void SetAutostartOs2( bool bActivate );
182cdf0e10cSrcweir 	        static bool GetAutostartOs2( );
183cdf0e10cSrcweir #endif
184cdf0e10cSrcweir };
185cdf0e10cSrcweir 
186cdf0e10cSrcweir extern "C" {
187cdf0e10cSrcweir #  ifdef WNT
188cdf0e10cSrcweir 	// builtin win32 systray
189cdf0e10cSrcweir 	void win32_init_sys_tray();
190cdf0e10cSrcweir 	void win32_shutdown_sys_tray();
191cdf0e10cSrcweir #  elif defined QUARTZ
192cdf0e10cSrcweir     void aqua_init_systray();
193cdf0e10cSrcweir     void aqua_shutdown_systray();
194cdf0e10cSrcweir #  endif
195cdf0e10cSrcweir 	// external plugin systray impl.
196cdf0e10cSrcweir 	void plugin_init_sys_tray();
197cdf0e10cSrcweir 	void plugin_shutdown_sys_tray();
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir #endif
201