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