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 48 class ResMgr; 49 namespace sfx2 50 { 51 class FileDialogHelper; 52 } 53 54 typedef ::cppu::WeakComponentImplHelper4< 55 ::com::sun::star::lang::XInitialization, 56 ::com::sun::star::frame::XTerminateListener, 57 ::com::sun::star::lang::XServiceInfo, 58 ::com::sun::star::beans::XFastPropertySet > ShutdownIconServiceBase; 59 60 #if defined(USE_APP_SHORTCUTS) 61 #define WRITER_URL "private:factory/swriter" 62 #define CALC_URL "private:factory/scalc" 63 #define IMPRESS_URL "private:factory/simpress" 64 #define IMPRESS_WIZARD_URL "private:factory/simpress?slot=6686" 65 #define DRAW_URL "private:factory/sdraw" 66 #define MATH_URL "private:factory/smath" 67 #define BASE_URL "private:factory/sdatabase?Interactive" 68 #define STARTMODULE_URL ".uno:ShowStartModule" 69 #endif 70 71 class SFX2_DLLPUBLIC ShutdownIcon : public ShutdownIconServiceBase 72 { 73 ::osl::Mutex m_aMutex; 74 bool m_bVeto; 75 bool m_bListenForTermination; 76 bool m_bSystemDialogs; 77 ResMgr* m_pResMgr; 78 sfx2::FileDialogHelper* m_pFileDlg; 79 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; 80 81 static ShutdownIcon *pShutdownIcon; // one instance 82 83 oslGenericFunction m_pInitSystray; 84 oslGenericFunction m_pDeInitSystray; 85 ::osl::Module *m_pPlugin; 86 87 bool m_bInitialized; 88 void initSystray(); 89 void deInitSystray(); 90 91 static bool LoadModule( osl::Module **pModule, 92 oslGenericFunction *pInit, 93 oslGenericFunction *pDeInit ); 94 static void EnterModalMode(); 95 static void LeaveModalMode(); 96 static rtl::OUString getShortcutName(); 97 98 friend class SfxNotificationListener_Impl; 99 100 public: 101 ShutdownIcon( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > aSMgr ); 102 103 virtual ~ShutdownIcon(); 104 105 SFX_DECL_XSERVICEINFO 106 107 static ShutdownIcon* getInstance(); 108 static ShutdownIcon* createInstance(); 109 110 static void terminateDesktop(); 111 static void addTerminateListener(); 112 113 static void FileOpen(); 114 static void OpenURL( const ::rtl::OUString& aURL, const ::rtl::OUString& rTarget, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& = 115 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >( 0 ) ); 116 static void FromTemplate(); 117 118 static void SetAutostart( bool bActivate ); 119 static bool GetAutostart(); 120 static bool bModalMode; 121 122 void init() throw( ::com::sun::star::uno::Exception ); 123 124 static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > 125 GetWrapperFactory( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSMgr ); 126 static ::rtl::OUString GetImplementationName_static(); 127 128 ::rtl::OUString GetResString( int id ); 129 ::rtl::OUString GetUrlDescription( const ::rtl::OUString& aUrl ); 130 131 void SetVeto( bool bVeto ) { m_bVeto = bVeto;} 132 bool GetVeto() { return m_bVeto; } 133 134 void StartFileDialog(); 135 sfx2::FileDialogHelper* GetFileDialog() const { return m_pFileDlg; } 136 static long DialogClosedHdl_Impl( ShutdownIcon*, sfx2::FileDialogHelper* ); 137 138 static bool IsQuickstarterInstalled(); 139 140 // Component Helper - force override 141 virtual void SAL_CALL disposing(); 142 143 // XEventListener 144 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) 145 throw(::com::sun::star::uno::RuntimeException); 146 147 // XTerminateListener 148 virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) 149 throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException); 150 virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) 151 throw(::com::sun::star::uno::RuntimeException); 152 153 // XInitialization 154 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) 155 throw( ::com::sun::star::uno::Exception ); 156 157 // XFastPropertySet 158 virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle, 159 const ::com::sun::star::uno::Any& aValue ) 160 throw (::com::sun::star::beans::UnknownPropertyException, 161 ::com::sun::star::beans::PropertyVetoException, 162 ::com::sun::star::lang::IllegalArgumentException, 163 ::com::sun::star::lang::WrappedTargetException, 164 ::com::sun::star::uno::RuntimeException); 165 virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle ) 166 throw (::com::sun::star::beans::UnknownPropertyException, 167 ::com::sun::star::lang::WrappedTargetException, 168 ::com::sun::star::uno::RuntimeException); 169 170 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop > m_xDesktop; 171 172 #ifdef WNT 173 static void EnableAutostartW32( const rtl::OUString &aShortcutName ); 174 static rtl::OUString GetAutostartFolderNameW32(); 175 #endif 176 #ifdef OS2 177 static void SetAutostartOs2( bool bActivate ); 178 static bool GetAutostartOs2( ); 179 #endif 180 }; 181 182 extern "C" { 183 # ifdef WNT 184 // builtin win32 systray 185 void win32_init_sys_tray(); 186 void win32_shutdown_sys_tray(); 187 # elif defined QUARTZ 188 void aqua_init_systray(); 189 void aqua_shutdown_systray(); 190 # endif 191 // external plugin systray impl. 192 void plugin_init_sys_tray(); 193 void plugin_shutdown_sys_tray(); 194 } 195 196 #endif 197