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/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 <rtl/string.hxx>
30 : #include <rtl/ustring.hxx>
31 : #include <osl/mutex.hxx>
32 : #include <osl/module.hxx>
33 : #include <sfx2/sfxuno.hxx>
34 : #include <cppuhelper/compbase4.hxx>
35 : #include <sfx2/dllapi.h>
36 :
37 : class ResMgr;
38 : namespace sfx2
39 : {
40 : class FileDialogHelper;
41 : }
42 :
43 : typedef ::cppu::WeakComponentImplHelper4<
44 : ::com::sun::star::lang::XInitialization,
45 : ::com::sun::star::frame::XTerminateListener,
46 : ::com::sun::star::lang::XServiceInfo,
47 : ::com::sun::star::beans::XFastPropertySet > ShutdownIconServiceBase;
48 :
49 : #if defined(USE_APP_SHORTCUTS)
50 : #define WRITER_URL "private:factory/swriter"
51 : #define CALC_URL "private:factory/scalc"
52 : #define IMPRESS_URL "private:factory/simpress"
53 : #define IMPRESS_WIZARD_URL "private:factory/simpress?slot=6686"
54 : #define DRAW_URL "private:factory/sdraw"
55 : #define MATH_URL "private:factory/smath"
56 : #define BASE_URL "private:factory/sdatabase?Interactive"
57 : #define STARTMODULE_URL ".uno:ShowStartModule"
58 : #endif
59 :
60 : class SFX2_DLLPUBLIC ShutdownIcon : public ShutdownIconServiceBase
61 : {
62 : ::osl::Mutex m_aMutex;
63 : bool m_bVeto;
64 : bool m_bListenForTermination;
65 : bool m_bSystemDialogs;
66 : ResMgr* m_pResMgr;
67 : sfx2::FileDialogHelper* m_pFileDlg;
68 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
69 :
70 : static ShutdownIcon *pShutdownIcon; // one instance
71 :
72 : oslGenericFunction m_pInitSystray;
73 : oslGenericFunction m_pDeInitSystray;
74 : ::osl::Module *m_pPlugin;
75 :
76 : bool m_bInitialized;
77 : void initSystray();
78 : void deInitSystray();
79 :
80 : static bool LoadModule( osl::Module **pModule,
81 : oslGenericFunction *pInit,
82 : oslGenericFunction *pDeInit );
83 : static void EnterModalMode();
84 : static void LeaveModalMode();
85 : static OUString getShortcutName();
86 :
87 : friend class SfxNotificationListener_Impl;
88 :
89 : public:
90 : ShutdownIcon( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext );
91 :
92 : virtual ~ShutdownIcon();
93 :
94 : virtual OUString SAL_CALL getImplementationName()
95 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 :
97 : virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
98 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 :
100 : virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
101 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 :
103 : static ShutdownIcon* getInstance();
104 : static ShutdownIcon* createInstance();
105 :
106 : static void terminateDesktop();
107 : static void addTerminateListener();
108 :
109 : static void FileOpen();
110 : static void OpenURL( const OUString& aURL, const OUString& rTarget, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& =
111 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >( 0 ) );
112 : static void FromTemplate();
113 :
114 : static void SetAutostart( bool bActivate );
115 : static bool GetAutostart();
116 : static bool bModalMode;
117 :
118 : void init() throw( ::com::sun::star::uno::Exception );
119 :
120 : OUString GetResString( int id );
121 : OUString GetUrlDescription( const 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() SAL_OVERRIDE;
134 :
135 : // XEventListener
136 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
137 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
142 : virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
143 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception ) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
161 :
162 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop2 > m_xDesktop;
163 :
164 : #ifdef WNT
165 : static void EnableAutostartW32( const OUString &aShortcutName );
166 : static 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 MACOSX
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: */
|