1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef __FRAMEWORK_SERVICES_SESSIONLISTENER_HXX_ 29 #define __FRAMEWORK_SERVICES_SESSIONLISTENER_HXX_ 30 31 //_______________________________________________ 32 // my own includes 33 34 #include <classes/filtercache.hxx> 35 #include <threadhelp/threadhelpbase.hxx> 36 #include <macros/generic.hxx> 37 #include <macros/debug.hxx> 38 #include <macros/xinterface.hxx> 39 #include <macros/xtypeprovider.hxx> 40 #include <macros/xserviceinfo.hxx> 41 #include <general.h> 42 43 //_______________________________________________ 44 // interface includes 45 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 46 #include <com/sun/star/lang/XInitialization.hpp> 47 48 49 #include <com/sun/star/frame/XSessionManagerListener2.hpp> 50 #include <com/sun/star/frame/XSessionManagerClient.hpp> 51 #include <com/sun/star/frame/XStatusListener.hpp> 52 #include <com/sun/star/frame/FeatureStateEvent.hpp> 53 #include <com/sun/star/lang/EventObject.hpp> 54 #include <com/sun/star/uno/Sequence.hxx> 55 #include <com/sun/star/uno/Any.hxx> 56 57 //_______________________________________________ 58 // other includes 59 #include <cppuhelper/weak.hxx> 60 #include <cppuhelper/interfacecontainer.h> 61 62 //_______________________________________________ 63 // namespace 64 65 namespace framework{ 66 67 //_______________________________________________ 68 // exported const 69 70 //_______________________________________________ 71 // exported definitions 72 73 /// @HTML 74 /** @short implements flat/deep detection of file/stream formats and provides 75 further read/write access to the global office type configuration. 76 77 @descr Using of this class makes it possible to get information about the 78 format type of a given URL or stream. The returned internal type name 79 can be used to get more informations about this format. Further this 80 class provides full access to the configuration data and following 81 implementations will support some special query modes. 82 83 @author as96863 84 85 @docdate 10.03.2003 by as96863 86 87 @todo <ul> 88 <li>implementation of query mode</li> 89 <li>simple restore mechanism of last consistent cache state, 90 if flush failed</li> 91 </ul> 92 */ 93 /// @NOHTML 94 95 class SessionListener : // interfaces 96 public css::lang::XTypeProvider, 97 public css::lang::XInitialization, 98 public css::frame::XSessionManagerListener2, 99 public css::frame::XStatusListener, 100 public css::lang::XServiceInfo, 101 // baseclasses (order important for initialization!) 102 // Struct for right initalization of mutex member! Must be the first one of baseclasses! 103 private ThreadHelpBase, 104 public ::cppu::OWeakObject 105 { 106 //------------------------------------------- 107 // member 108 109 private: 110 111 /** reference to the uno service manager, which created this service. 112 It can be used to create own needed helper services. */ 113 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; 114 115 css::uno::Reference< css::frame::XSessionManagerClient > m_rSessionManager; 116 117 // restore handling 118 sal_Bool m_bRestored; 119 120 sal_Bool m_bSessionStoreRequested; 121 122 sal_Bool m_bAllowUserInteractionOnQuit; 123 sal_Bool m_bTerminated; 124 125 126 // in case of synchronous call the caller should do saveDone() call himself! 127 void StoreSession( sal_Bool bAsync ); 128 129 // let session quietly close the documents, remove lock files, store configuration and etc. 130 void QuitSessionQuietly(); 131 132 public: 133 134 //--------------------------------------- 135 // XInterface, XTypeProvider, XServiceInfo 136 137 FWK_DECLARE_XINTERFACE 138 FWK_DECLARE_XTYPEPROVIDER 139 DECLARE_XSERVICEINFO 140 141 #ifdef ENABLE_AUTODOC_FIX 142 ; 143 #endif 144 145 //--------------------------------------- 146 147 /** @short initialize new instance of this class. 148 149 @param xSMGR 150 reference to the global uno service manager, which created this new 151 factory instance. It must be used during runtime to create own 152 needed services. 153 */ 154 155 SessionListener( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ); 156 157 virtual ~SessionListener(); 158 159 virtual void SAL_CALL disposing(const com::sun::star::lang::EventObject&) throw (css::uno::RuntimeException); 160 161 162 // XInitialization 163 virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& args) throw (css::uno::RuntimeException); 164 165 // XSessionManagerListener 166 virtual void SAL_CALL doSave( sal_Bool bShutdown, sal_Bool bCancelable ) 167 throw (css::uno::RuntimeException); 168 virtual void SAL_CALL approveInteraction( sal_Bool bInteractionGranted ) 169 throw (css::uno::RuntimeException); 170 virtual void SAL_CALL shutdownCanceled() 171 throw (css::uno::RuntimeException); 172 virtual sal_Bool SAL_CALL doRestore() 173 throw (css::uno::RuntimeException); 174 175 // XSessionManagerListener2 176 virtual void SAL_CALL doQuit() 177 throw (::com::sun::star::uno::RuntimeException); 178 179 // XStatusListener 180 virtual void SAL_CALL statusChanged(const com::sun::star::frame::FeatureStateEvent& event) 181 throw (css::uno::RuntimeException); 182 183 void doSaveImpl( sal_Bool bShutdown, sal_Bool bCancelable ) throw (css::uno::RuntimeException); 184 }; 185 186 } // namespace framework 187 188 #endif // #ifndef __FRAMEWORK_SERVICES_TYPEDETECTION_HXX_ 189