1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef __SHUTDOWNICON_HXX__
21 #define __SHUTDOWNICON_HXX__
23 #include <com/sun/star/frame/XTerminateListener.hpp>
24 #include <com/sun/star/frame/XDesktop2.hpp>
25 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/lang/XComponent.hpp>
28 #include <com/sun/star/lang/XEventListener.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/lang/XInitialization.hpp>
31 #include <com/sun/star/beans/XFastPropertySet.hpp>
32 #include <rtl/string.hxx>
33 #include <rtl/ustring.hxx>
34 #include <osl/mutex.hxx>
35 #include <osl/module.hxx>
36 #include <sfx2/sfxuno.hxx>
37 #include <cppuhelper/compbase4.hxx>
38 #include <sfx2/dllapi.h>
43 class FileDialogHelper
;
46 typedef ::cppu::WeakComponentImplHelper4
<
47 ::com::sun::star::lang::XInitialization
,
48 ::com::sun::star::frame::XTerminateListener
,
49 ::com::sun::star::lang::XServiceInfo
,
50 ::com::sun::star::beans::XFastPropertySet
> ShutdownIconServiceBase
;
52 #if defined(USE_APP_SHORTCUTS)
53 #define WRITER_URL "private:factory/swriter"
54 #define CALC_URL "private:factory/scalc"
55 #define IMPRESS_URL "private:factory/simpress"
56 #define IMPRESS_WIZARD_URL "private:factory/simpress?slot=6686"
57 #define DRAW_URL "private:factory/sdraw"
58 #define MATH_URL "private:factory/smath"
59 #define BASE_URL "private:factory/sdatabase?Interactive"
60 #define STARTMODULE_URL ".uno:ShowStartModule"
63 class SFX2_DLLPUBLIC ShutdownIcon
: public ShutdownIconServiceBase
65 ::osl::Mutex m_aMutex
;
67 bool m_bListenForTermination
;
68 bool m_bSystemDialogs
;
70 sfx2::FileDialogHelper
* m_pFileDlg
;
71 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
73 static ShutdownIcon
*pShutdownIcon
; // one instance
75 oslGenericFunction m_pInitSystray
;
76 oslGenericFunction m_pDeInitSystray
;
77 ::osl::Module
*m_pPlugin
;
83 static bool LoadModule( osl::Module
**pModule
,
84 oslGenericFunction
*pInit
,
85 oslGenericFunction
*pDeInit
);
86 static void EnterModalMode();
87 static void LeaveModalMode();
88 static OUString
getShortcutName();
90 friend class SfxNotificationListener_Impl
;
93 ShutdownIcon( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> & rxContext
);
95 virtual ~ShutdownIcon();
99 static ShutdownIcon
* getInstance();
100 static ShutdownIcon
* createInstance();
102 static void terminateDesktop();
103 static void addTerminateListener();
105 static void FileOpen();
106 static void OpenURL( const OUString
& aURL
, const OUString
& rTarget
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& =
107 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>( 0 ) );
108 static void FromTemplate();
110 static void SetAutostart( bool bActivate
);
111 static bool GetAutostart();
112 static bool bModalMode
;
114 void init() throw( ::com::sun::star::uno::Exception
);
116 static ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XSingleServiceFactory
>
117 GetWrapperFactory( ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & xSMgr
);
118 static OUString
GetImplementationName_static();
120 OUString
GetResString( int id
);
121 OUString
GetUrlDescription( const OUString
& aUrl
);
123 void SetVeto( bool bVeto
) { m_bVeto
= bVeto
;}
124 bool GetVeto() { return m_bVeto
; }
126 void StartFileDialog();
127 sfx2::FileDialogHelper
* GetFileDialog() const { return m_pFileDlg
; }
128 static long DialogClosedHdl_Impl( ShutdownIcon
*, sfx2::FileDialogHelper
* );
130 static bool IsQuickstarterInstalled();
132 // Component Helper - force override
133 virtual void SAL_CALL
disposing();
136 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
)
137 throw(::com::sun::star::uno::RuntimeException
);
139 // XTerminateListener
140 virtual void SAL_CALL
queryTermination( const ::com::sun::star::lang::EventObject
& aEvent
)
141 throw(::com::sun::star::frame::TerminationVetoException
, ::com::sun::star::uno::RuntimeException
);
142 virtual void SAL_CALL
notifyTermination( const ::com::sun::star::lang::EventObject
& aEvent
)
143 throw(::com::sun::star::uno::RuntimeException
);
146 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
)
147 throw( ::com::sun::star::uno::Exception
);
150 virtual void SAL_CALL
setFastPropertyValue( ::sal_Int32 nHandle
,
151 const ::com::sun::star::uno::Any
& aValue
)
152 throw (::com::sun::star::beans::UnknownPropertyException
,
153 ::com::sun::star::beans::PropertyVetoException
,
154 ::com::sun::star::lang::IllegalArgumentException
,
155 ::com::sun::star::lang::WrappedTargetException
,
156 ::com::sun::star::uno::RuntimeException
);
157 virtual ::com::sun::star::uno::Any SAL_CALL
getFastPropertyValue( ::sal_Int32 nHandle
)
158 throw (::com::sun::star::beans::UnknownPropertyException
,
159 ::com::sun::star::lang::WrappedTargetException
,
160 ::com::sun::star::uno::RuntimeException
);
162 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDesktop2
> m_xDesktop
;
165 static void EnableAutostartW32( const OUString
&aShortcutName
);
166 static OUString
GetAutostartFolderNameW32();
172 // builtin win32 systray
173 void win32_init_sys_tray();
174 void win32_shutdown_sys_tray();
175 # elif defined MACOSX
176 void aqua_init_systray();
177 void aqua_shutdown_systray();
179 // external plugin systray impl.
180 void plugin_init_sys_tray();
181 void plugin_shutdown_sys_tray();
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */