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 <sfx2/sfxuno.hxx>
33 : #include <cppuhelper/compbase4.hxx>
34 : #include <sfx2/dllapi.h>
35 : #include <tools/link.hxx>
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 : bool m_bInitialized;
73 : void initSystray();
74 : void deInitSystray();
75 :
76 : static void EnterModalMode();
77 : static void LeaveModalMode();
78 : static OUString getShortcutName();
79 :
80 : friend class SfxNotificationListener_Impl;
81 :
82 : public:
83 : ShutdownIcon( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext );
84 :
85 : virtual ~ShutdownIcon();
86 :
87 : virtual OUString SAL_CALL getImplementationName()
88 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 :
90 : virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
91 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 :
93 : virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
94 : throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 :
96 : static ShutdownIcon* getInstance();
97 : static ShutdownIcon* createInstance();
98 :
99 : static void terminateDesktop();
100 : static void addTerminateListener();
101 :
102 : static void FileOpen();
103 : static void OpenURL( const OUString& aURL, const OUString& rTarget, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& =
104 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >( 0 ) );
105 : static void FromTemplate();
106 :
107 : static void SetAutostart( bool bActivate );
108 : static bool GetAutostart();
109 : static bool bModalMode;
110 :
111 : void init() throw( ::com::sun::star::uno::Exception );
112 :
113 : OUString GetResString( int id );
114 : OUString GetUrlDescription( const OUString& aUrl );
115 :
116 0 : void SetVeto( bool bVeto ) { m_bVeto = bVeto;}
117 : bool GetVeto() { return m_bVeto; }
118 :
119 : void StartFileDialog();
120 : sfx2::FileDialogHelper* GetFileDialog() const { return m_pFileDlg; }
121 : DECL_STATIC_LINK(
122 : ShutdownIcon, DialogClosedHdl_Impl, sfx2::FileDialogHelper*);
123 :
124 : static bool IsQuickstarterInstalled();
125 :
126 : // Component Helper - force override
127 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
128 :
129 : // XEventListener
130 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
131 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
132 :
133 : // XTerminateListener
134 : virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent )
135 : throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
136 : virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
137 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
138 :
139 : // XInitialization
140 : virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
141 : throw( ::com::sun::star::uno::Exception, std::exception ) SAL_OVERRIDE;
142 :
143 : // XFastPropertySet
144 : virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle,
145 : const ::com::sun::star::uno::Any& aValue )
146 : throw (::com::sun::star::beans::UnknownPropertyException,
147 : ::com::sun::star::beans::PropertyVetoException,
148 : ::com::sun::star::lang::IllegalArgumentException,
149 : ::com::sun::star::lang::WrappedTargetException,
150 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
151 : virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle )
152 : throw (::com::sun::star::beans::UnknownPropertyException,
153 : ::com::sun::star::lang::WrappedTargetException,
154 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 :
156 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop2 > m_xDesktop;
157 :
158 : #ifdef WNT
159 : static void EnableAutostartW32( const OUString &aShortcutName );
160 : static OUString GetAutostartFolderNameW32();
161 : #endif
162 : };
163 :
164 : extern "C" {
165 : # ifdef WNT
166 : // builtin win32 systray
167 : void win32_init_sys_tray();
168 : void win32_shutdown_sys_tray();
169 : # elif defined MACOSX
170 : void aqua_init_systray();
171 : void aqua_shutdown_systray();
172 : # endif
173 : // external plugin systray impl.
174 : void plugin_init_sys_tray();
175 : void plugin_shutdown_sys_tray();
176 : }
177 :
178 : #endif
179 :
180 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|