xref: /aoo41x/main/sfx2/source/appl/shutdownicon.hxx (revision cdf0e10c)
1 
2 #ifndef __SHUTDOWNICON_HXX__
3 #define __SHUTDOWNICON_HXX__
4 
5 #include <com/sun/star/frame/XTerminateListener.hpp>
6 #include <com/sun/star/frame/XDesktop.hpp>
7 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
8 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
9 #include <com/sun/star/lang/XComponent.hpp>
10 #include <com/sun/star/lang/XEventListener.hpp>
11 #include <com/sun/star/lang/XServiceInfo.hpp>
12 #include <com/sun/star/lang/XInitialization.hpp>
13 #include <com/sun/star/lang/XInitialization.hpp>
14 #include <com/sun/star/beans/XFastPropertySet.hpp>
15 #ifndef _RTL_STRING_HXX
16 #include <rtl/string.hxx>
17 #endif
18 #ifndef _RTL_USTRING_HXX
19 #include <rtl/ustring.hxx>
20 #endif
21 #include <osl/mutex.hxx>
22 #include <osl/module.hxx>
23 #include <sfx2/sfxuno.hxx>
24 #include <cppuhelper/compbase4.hxx>
25 #include <sfx2/dllapi.h>
26 
27 class ResMgr;
28 namespace sfx2
29 {
30     class FileDialogHelper;
31 }
32 
33 typedef ::cppu::WeakComponentImplHelper4<
34 	::com::sun::star::lang::XInitialization,
35 	::com::sun::star::frame::XTerminateListener,
36 	::com::sun::star::lang::XServiceInfo,
37     ::com::sun::star::beans::XFastPropertySet > ShutdownIconServiceBase;
38 
39 #if defined(USE_APP_SHORTCUTS)
40 #define WRITER_URL      "private:factory/swriter"
41 #define CALC_URL        "private:factory/scalc"
42 #define IMPRESS_URL     "private:factory/simpress"
43 #define IMPRESS_WIZARD_URL     "private:factory/simpress?slot=6686"
44 #define DRAW_URL        "private:factory/sdraw"
45 #define MATH_URL        "private:factory/smath"
46 #define BASE_URL        "private:factory/sdatabase?Interactive"
47 #define STARTMODULE_URL ".uno:ShowStartModule"
48 #endif
49 
50 class SFX2_DLLPUBLIC ShutdownIcon :	public ShutdownIconServiceBase
51 {
52         ::osl::Mutex            m_aMutex;
53         bool                    m_bVeto;
54         bool                    m_bListenForTermination;
55         bool                    m_bSystemDialogs;
56         ResMgr*                 m_pResMgr;
57         sfx2::FileDialogHelper* m_pFileDlg;
58 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
59 
60         static ShutdownIcon *pShutdownIcon; // one instance
61 
62 		oslGenericFunction m_pInitSystray;
63 		oslGenericFunction m_pDeInitSystray;
64 		::osl::Module  *m_pPlugin;
65 
66 		bool m_bInitialized;
67 		void initSystray();
68 		void deInitSystray();
69 
70 		static bool LoadModule( osl::Module **pModule,
71 								oslGenericFunction *pInit,
72 								oslGenericFunction *pDeInit );
73 		static void EnterModalMode();
74 		static void LeaveModalMode();
75 		static rtl::OUString getShortcutName();
76 
77 		friend class SfxNotificationListener_Impl;
78 
79 	public:
80 		ShutdownIcon( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > aSMgr );
81 
82 		virtual ~ShutdownIcon();
83 
84         SFX_DECL_XSERVICEINFO
85 
86 		static ShutdownIcon* getInstance();
87 		static ShutdownIcon* createInstance();
88 
89         static void terminateDesktop();
90 		static void addTerminateListener();
91 
92         static void FileOpen();
93         static void OpenURL( const ::rtl::OUString& aURL, const ::rtl::OUString& rTarget, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& =
94 			::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >( 0 ) );
95         static void FromTemplate();
96 
97         static void SetAutostart( bool bActivate );
98         static bool GetAutostart();
99 		static bool bModalMode;
100 
101 		void init() throw( ::com::sun::star::uno::Exception );
102 
103 		static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory >
104 					GetWrapperFactory( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSMgr );
105 		static ::rtl::OUString  GetImplementationName_static();
106 
107         ::rtl::OUString GetResString( int id );
108         ::rtl::OUString GetUrlDescription( const ::rtl::OUString& aUrl );
109 
110         void SetVeto( bool bVeto )  { m_bVeto = bVeto;}
111         bool GetVeto()              { return m_bVeto; }
112 
113         void                    StartFileDialog();
114         sfx2::FileDialogHelper* GetFileDialog() const { return m_pFileDlg; }
115         static long DialogClosedHdl_Impl( ShutdownIcon*, sfx2::FileDialogHelper* );
116 
117         static bool IsQuickstarterInstalled();
118 
119 		// Component Helper - force override
120 		virtual void SAL_CALL disposing();
121 
122 		// XEventListener
123 		virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
124 			throw(::com::sun::star::uno::RuntimeException);
125 
126 		// XTerminateListener
127 		virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent )
128 			throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
129 		virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
130 			throw(::com::sun::star::uno::RuntimeException);
131 
132 		// XInitialization
133 		virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
134 			throw( ::com::sun::star::uno::Exception );
135 
136         // XFastPropertySet
137         virtual void SAL_CALL setFastPropertyValue(       ::sal_Int32                  nHandle,
138                                                     const ::com::sun::star::uno::Any& aValue )
139             throw (::com::sun::star::beans::UnknownPropertyException,
140                     ::com::sun::star::beans::PropertyVetoException,
141                     ::com::sun::star::lang::IllegalArgumentException,
142                     ::com::sun::star::lang::WrappedTargetException,
143                     ::com::sun::star::uno::RuntimeException);
144         virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle )
145             throw (::com::sun::star::beans::UnknownPropertyException,
146                     ::com::sun::star::lang::WrappedTargetException,
147                     ::com::sun::star::uno::RuntimeException);
148 
149 		::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > m_xDesktop;
150 
151 #ifdef WNT
152 		static void EnableAutostartW32( const rtl::OUString &aShortcutName );
153 		static rtl::OUString GetAutostartFolderNameW32();
154 #endif
155 #ifdef OS2
156 	        static void SetAutostartOs2( bool bActivate );
157 	        static bool GetAutostartOs2( );
158 #endif
159 };
160 
161 extern "C" {
162 #  ifdef WNT
163 	// builtin win32 systray
164 	void win32_init_sys_tray();
165 	void win32_shutdown_sys_tray();
166 #  elif defined QUARTZ
167     void aqua_init_systray();
168     void aqua_shutdown_systray();
169 #  endif
170 	// external plugin systray impl.
171 	void plugin_init_sys_tray();
172 	void plugin_shutdown_sys_tray();
173 }
174 
175 #endif
176