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