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 : static 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_LINK(DialogClosedHdl_Impl, sfx2::FileDialogHelper*);
122 :
123 : static bool IsQuickstarterInstalled();
124 :
125 : // Component Helper - force override
126 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
127 :
128 : // XEventListener
129 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
130 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 :
132 : // XTerminateListener
133 : virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent )
134 : throw(::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135 : virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
136 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
137 :
138 : // XInitialization
139 : virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
140 : throw( ::com::sun::star::uno::Exception, std::exception ) SAL_OVERRIDE;
141 :
142 : // XFastPropertySet
143 : virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle,
144 : const ::com::sun::star::uno::Any& aValue )
145 : throw (::com::sun::star::beans::UnknownPropertyException,
146 : ::com::sun::star::beans::PropertyVetoException,
147 : ::com::sun::star::lang::IllegalArgumentException,
148 : ::com::sun::star::lang::WrappedTargetException,
149 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
150 : virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle )
151 : throw (::com::sun::star::beans::UnknownPropertyException,
152 : ::com::sun::star::lang::WrappedTargetException,
153 : ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
154 :
155 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop2 > m_xDesktop;
156 :
157 : #ifdef WNT
158 : static void EnableAutostartW32( const OUString &aShortcutName );
159 : static OUString GetAutostartFolderNameW32();
160 : #endif
161 : };
162 :
163 : extern "C" {
164 : # ifdef WNT
165 : // builtin win32 systray
166 : void win32_init_sys_tray();
167 : void win32_shutdown_sys_tray();
168 : # elif defined MACOSX
169 : void aqua_init_systray();
170 : void aqua_shutdown_systray();
171 : # endif
172 : }
173 :
174 : #endif
175 :
176 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|