1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef __FRAMEWORK_SERVICES_SESSIONLISTENER_HXX_
21 #define __FRAMEWORK_SERVICES_SESSIONLISTENER_HXX_
23 #include <classes/filtercache.hxx>
24 #include <threadhelp/threadhelpbase.hxx>
25 #include <macros/generic.hxx>
26 #include <macros/debug.hxx>
27 #include <macros/xinterface.hxx>
28 #include <macros/xtypeprovider.hxx>
29 #include <macros/xserviceinfo.hxx>
32 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33 #include <com/sun/star/lang/XInitialization.hpp>
36 #include <com/sun/star/frame/XSessionManagerListener2.hpp>
37 #include <com/sun/star/frame/XSessionManagerClient.hpp>
38 #include <com/sun/star/frame/XStatusListener.hpp>
39 #include <com/sun/star/frame/FeatureStateEvent.hpp>
40 #include <com/sun/star/lang/EventObject.hpp>
41 #include <com/sun/star/uno/Sequence.hxx>
42 #include <com/sun/star/uno/Any.hxx>
44 #include <cppuhelper/weak.hxx>
45 #include <cppuhelper/interfacecontainer.h>
50 /** @short implements flat/deep detection of file/stream formats and provides
51 further read/write access to the global office type configuration.
53 @descr Using of this class makes it possible to get information about the
54 format type of a given URL or stream. The returned internal type name
55 can be used to get more information about this format. Further this
56 class provides full access to the configuration data and following
57 implementations will support some special query modes.
61 @docdate 10.03.2003 by as96863
64 <li>implementation of query mode</li>
65 <li>simple restore mechanism of last consistent cache state,
70 class SessionListener
: // interfaces
71 public css::lang::XTypeProvider
,
72 public css::lang::XInitialization
,
73 public css::frame::XSessionManagerListener2
,
74 public css::frame::XStatusListener
,
75 public css::lang::XServiceInfo
,
76 // baseclasses (order important for initialization!)
77 // Struct for right initalization of mutex member! Must be the first one of baseclasses!
78 private ThreadHelpBase
,
79 public ::cppu::OWeakObject
81 //-------------------------------------------
86 /** reference to the uno service manager, which created this service.
87 It can be used to create own needed helper services. */
88 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xSMGR
;
90 css::uno::Reference
< css::frame::XSessionManagerClient
> m_rSessionManager
;
95 sal_Bool m_bSessionStoreRequested
;
97 sal_Bool m_bAllowUserInteractionOnQuit
;
98 sal_Bool m_bTerminated
;
101 // in case of synchronous call the caller should do saveDone() call himself!
102 void StoreSession( sal_Bool bAsync
);
104 // let session quietly close the documents, remove lock files, store configuration and etc.
105 void QuitSessionQuietly();
109 //---------------------------------------
110 // XInterface, XTypeProvider, XServiceInfo
112 FWK_DECLARE_XINTERFACE
113 FWK_DECLARE_XTYPEPROVIDER
116 //---------------------------------------
118 /** @short initialize new instance of this class.
121 reference to the global uno service manager, which created this new
122 factory instance. It must be used during runtime to create own
126 SessionListener( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xSMGR
);
128 virtual ~SessionListener();
130 virtual void SAL_CALL
disposing(const com::sun::star::lang::EventObject
&) throw (css::uno::RuntimeException
);
134 virtual void SAL_CALL
initialize(const css::uno::Sequence
< css::uno::Any
>& args
) throw (css::uno::RuntimeException
);
136 // XSessionManagerListener
137 virtual void SAL_CALL
doSave( sal_Bool bShutdown
, sal_Bool bCancelable
)
138 throw (css::uno::RuntimeException
);
139 virtual void SAL_CALL
approveInteraction( sal_Bool bInteractionGranted
)
140 throw (css::uno::RuntimeException
);
141 virtual void SAL_CALL
shutdownCanceled()
142 throw (css::uno::RuntimeException
);
143 virtual sal_Bool SAL_CALL
doRestore()
144 throw (css::uno::RuntimeException
);
146 // XSessionManagerListener2
147 virtual void SAL_CALL
doQuit()
148 throw (::com::sun::star::uno::RuntimeException
);
151 virtual void SAL_CALL
statusChanged(const com::sun::star::frame::FeatureStateEvent
& event
)
152 throw (css::uno::RuntimeException
);
154 void doSaveImpl( sal_Bool bShutdown
, sal_Bool bCancelable
) throw (css::uno::RuntimeException
);
157 } // namespace framework
159 #endif // #ifndef __FRAMEWORK_SERVICES_SESSIONLISTENER_HXX_
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */