1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_SFX2_SOURCE_APPL_SHUTDOWNICON_HXX 21 #define INCLUDED_SFX2_SOURCE_APPL_SHUTDOWNICON_HXX 22 23 #include <com/sun/star/frame/XTerminateListener.hpp> 24 #include <com/sun/star/frame/XDesktop2.hpp> 25 #include <com/sun/star/lang/XEventListener.hpp> 26 #include <com/sun/star/lang/XServiceInfo.hpp> 27 #include <com/sun/star/lang/XInitialization.hpp> 28 #include <com/sun/star/beans/XFastPropertySet.hpp> 29 #include <com/sun/star/uno/XComponentContext.hpp> 30 #include <rtl/string.hxx> 31 #include <rtl/ustring.hxx> 32 #include <osl/mutex.hxx> 33 #include <sfx2/sfxuno.hxx> 34 #include <cppuhelper/compbase.hxx> 35 #include <sfx2/dllapi.h> 36 #include <tools/link.hxx> 37 #include <memory> 38 39 extern "C" { 40 41 void SAL_DLLPUBLIC_EXPORT plugin_init_sys_tray(); 42 void SAL_DLLPUBLIC_EXPORT plugin_shutdown_sys_tray(); 43 44 } 45 46 namespace sfx2 47 { 48 class FileDialogHelper; 49 } 50 51 typedef ::cppu::WeakComponentImplHelper< 52 css::lang::XInitialization, 53 css::frame::XTerminateListener, 54 css::lang::XServiceInfo, 55 css::beans::XFastPropertySet > ShutdownIconServiceBase; 56 57 #define WRITER_URL "private:factory/swriter" 58 #define CALC_URL "private:factory/scalc" 59 #define IMPRESS_URL "private:factory/simpress" 60 #define IMPRESS_WIZARD_URL "private:factory/simpress?slot=6686" 61 #define DRAW_URL "private:factory/sdraw" 62 #define MATH_URL "private:factory/smath" 63 #define BASE_URL "private:factory/sdatabase?Interactive" 64 #define STARTMODULE_URL ".uno:ShowStartModule" 65 66 class ShutdownIcon : public ShutdownIconServiceBase 67 { 68 ::osl::Mutex m_aMutex; 69 bool m_bVeto; 70 bool m_bListenForTermination; 71 bool m_bSystemDialogs; 72 std::unique_ptr<sfx2::FileDialogHelper> m_pFileDlg; 73 css::uno::Reference< css::uno::XComponentContext > m_xContext; 74 75 static ShutdownIcon *pShutdownIcon; // one instance 76 77 bool m_bInitialized; 78 void initSystray(); 79 void deInitSystray(); 80 81 static void EnterModalMode(); 82 static void LeaveModalMode(); 83 static OUString getShortcutName(); 84 85 friend class SfxNotificationListener_Impl; 86 87 public: 88 explicit ShutdownIcon( const css::uno::Reference< css::uno::XComponentContext > & rxContext ); 89 90 virtual ~ShutdownIcon() override; 91 92 virtual OUString SAL_CALL getImplementationName() override; 93 94 virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; 95 96 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; 97 98 static ShutdownIcon* getInstance(); 99 static ShutdownIcon* createInstance(); 100 101 static void terminateDesktop(); 102 static void addTerminateListener(); 103 104 static void FileOpen(); 105 static void OpenURL( const OUString& aURL, const OUString& rTarget, const css::uno::Sequence< css::beans::PropertyValue >& = 106 css::uno::Sequence< css::beans::PropertyValue >( 0 ) ); 107 static void FromTemplate(); 108 109 static void SetAutostart( bool bActivate ); 110 static bool GetAutostart(); 111 static bool bModalMode; 112 113 /// @throws css::uno::Exception 114 void init(); 115 116 static OUString GetUrlDescription( const OUString& aUrl ); 117 SetVeto(bool bVeto)118 void SetVeto( bool bVeto ) { m_bVeto = bVeto;} 119 120 void StartFileDialog(); 121 DECL_LINK(DialogClosedHdl_Impl, sfx2::FileDialogHelper*, void); 122 123 static bool IsQuickstarterInstalled(); 124 125 // Component Helper - force override 126 virtual void SAL_CALL disposing() override; 127 128 // XEventListener 129 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; 130 131 // XTerminateListener 132 virtual void SAL_CALL queryTermination( const css::lang::EventObject& aEvent ) override; 133 virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aEvent ) override; 134 135 // XInitialization 136 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; 137 138 // XFastPropertySet 139 virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle, 140 const css::uno::Any& aValue ) override; 141 virtual css::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle ) override; 142 143 css::uno::Reference< css::frame::XDesktop2 > m_xDesktop; 144 145 #ifdef _WIN32 146 static void EnableAutostartW32( const OUString &aShortcutName ); 147 static OUString GetAutostartFolderNameW32(); 148 #endif 149 }; 150 151 extern "C" { 152 # ifdef WNT 153 // builtin win32 systray 154 void win32_init_sys_tray(); 155 void win32_shutdown_sys_tray(); 156 # elif defined MACOSX 157 void aqua_init_systray(); 158 void aqua_shutdown_systray(); 159 # endif 160 } 161 162 #endif 163 164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 165