Line data Source code
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 __SHUTDOWNICON_HXX__
21 : #define __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/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>
39 :
40 : class ResMgr;
41 : namespace sfx2
42 : {
43 : class FileDialogHelper;
44 : }
45 :
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;
51 :
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"
61 : #endif
62 :
63 : class SFX2_DLLPUBLIC ShutdownIcon : public ShutdownIconServiceBase
64 : {
65 : ::osl::Mutex m_aMutex;
66 : bool m_bVeto;
67 : bool m_bListenForTermination;
68 : bool m_bSystemDialogs;
69 : ResMgr* m_pResMgr;
70 : sfx2::FileDialogHelper* m_pFileDlg;
71 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
72 :
73 : static ShutdownIcon *pShutdownIcon; // one instance
74 :
75 : oslGenericFunction m_pInitSystray;
76 : oslGenericFunction m_pDeInitSystray;
77 : ::osl::Module *m_pPlugin;
78 :
79 : bool m_bInitialized;
80 : void initSystray();
81 : void deInitSystray();
82 :
83 : static bool LoadModule( osl::Module **pModule,
84 : oslGenericFunction *pInit,
85 : oslGenericFunction *pDeInit );
86 : static void EnterModalMode();
87 : static void LeaveModalMode();
88 : static rtl::OUString getShortcutName();
89 :
90 : friend class SfxNotificationListener_Impl;
91 :
92 : public:
93 : ShutdownIcon( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext );
94 :
95 : virtual ~ShutdownIcon();
96 :
97 : SFX_DECL_XSERVICEINFO
98 :
99 : static ShutdownIcon* getInstance();
100 : static ShutdownIcon* createInstance();
101 :
102 : static void terminateDesktop();
103 : static void addTerminateListener();
104 :
105 : static void FileOpen();
106 : static void OpenURL( const ::rtl::OUString& aURL, const ::rtl::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();
109 :
110 : static void SetAutostart( bool bActivate );
111 : static bool GetAutostart();
112 : static bool bModalMode;
113 :
114 : void init() throw( ::com::sun::star::uno::Exception );
115 :
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 ::rtl::OUString GetImplementationName_static();
119 :
120 : ::rtl::OUString GetResString( int id );
121 : ::rtl::OUString GetUrlDescription( const ::rtl::OUString& aUrl );
122 :
123 0 : void SetVeto( bool bVeto ) { m_bVeto = bVeto;}
124 : bool GetVeto() { return m_bVeto; }
125 :
126 : void StartFileDialog();
127 : sfx2::FileDialogHelper* GetFileDialog() const { return m_pFileDlg; }
128 : static long DialogClosedHdl_Impl( ShutdownIcon*, sfx2::FileDialogHelper* );
129 :
130 : static bool IsQuickstarterInstalled();
131 :
132 : // Component Helper - force override
133 : virtual void SAL_CALL disposing();
134 :
135 : // XEventListener
136 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
137 : throw(::com::sun::star::uno::RuntimeException);
138 :
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);
144 :
145 : // XInitialization
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 );
148 :
149 : // XFastPropertySet
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);
161 :
162 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop2 > m_xDesktop;
163 :
164 : #ifdef WNT
165 : static void EnableAutostartW32( const rtl::OUString &aShortcutName );
166 : static rtl::OUString GetAutostartFolderNameW32();
167 : #endif
168 : };
169 :
170 : extern "C" {
171 : # ifdef WNT
172 : // builtin win32 systray
173 : void win32_init_sys_tray();
174 : void win32_shutdown_sys_tray();
175 : # elif defined QUARTZ
176 : void aqua_init_systray();
177 : void aqua_shutdown_systray();
178 : # endif
179 : // external plugin systray impl.
180 : void plugin_init_sys_tray();
181 : void plugin_shutdown_sys_tray();
182 : }
183 :
184 : #endif
185 :
186 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|