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_INTERACTION_QUIETINTERACTION_HXX_
25 #define __FRAMEWORK_INTERACTION_QUIETINTERACTION_HXX_
26 
27 //_________________________________________________________________________________________________________________
28 //	my own includes
29 //_________________________________________________________________________________________________________________
30 
31 #include <threadhelp/threadhelpbase.hxx>
32 #include <macros/xinterface.hxx>
33 #include <macros/xtypeprovider.hxx>
34 #include <general.h>
35 
36 //_________________________________________________________________________________________________________________
37 //	interface includes
38 //_________________________________________________________________________________________________________________
39 #include <com/sun/star/task/XInteractionHandler.hpp>
40 #include <com/sun/star/task/XInteractionRequest.hpp>
41 
42 //_________________________________________________________________________________________________________________
43 //	other includes
44 //_________________________________________________________________________________________________________________
45 #include <cppuhelper/weak.hxx>
46 
47 //_________________________________________________________________________________________________________________
48 //	namespace
49 //_________________________________________________________________________________________________________________
50 
51 namespace framework{
52 
53 //_________________________________________________________________________________________________________________
54 //	exported const
55 //_________________________________________________________________________________________________________________
56 
57 //_________________________________________________________________________________________________________________
58 //	exported definitions
59 //_________________________________________________________________________________________________________________
60 
61 /**
62     @short      handle interactions non visible
63     @descr      Sometimes it's necessary to use a non visible interaction handler.
64                 He can't do anything, which a visible one can handle.
65                 But it can be used to intercept problems e.g. during loading of documents.
66 
67                 In current implementation we solve conflicts for following situations only:
68                     - AmbigousFilterRequest
69                     - InteractiveIOException
70                     - InteractiveAugmentedIOException
71                 All other requests will be aborted.
72 
73     @modified   12.07.2002 14:06
74     @by         Andreas Schl�ns
75  */
76 class QuietInteraction : public  css::lang::XTypeProvider
77                        , public  css::task::XInteractionHandler
78                        , private ThreadHelpBase
79                        , public  ::cppu::OWeakObject
80 {
81     //_____________________________________
82     // member
83     private:
84 
85         /// in case an unknown interaction was aborted - we save it for our external user!
86         css::uno::Any m_aRequest;
87 
88     //_____________________________________
89     // uno interface
90     public:
91 
92         // XInterface, XTypeProvider
93         FWK_DECLARE_XINTERFACE
94         FWK_DECLARE_XTYPEPROVIDER
95 
96         //_________________________________
97         /**
98             @interface  XInteractionHandler
99             @short      called from outside to handle a problem
100             @descr      The only interaction we can handle here is to
101                         decide which of two ambigous filters should be really used.
102                         We use the user selected one every time.
103                         All other request will be aborted and can break the code,
104                         which use this interaction handler.
105 
106                         But you can use another method of this class to check for
107                         some special interactions too: IO Exceptions
108                         May a ComponentLoader needs that to throw suitable exception
109                         on his own interface.
110 
111             @threadsafe yes
112         */
113         virtual void SAL_CALL handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) throw( css::uno::RuntimeException );
114 
115     //_____________________________________
116     // c++ interface
117     public:
118 
119         //_________________________________
120         /**
121             @short      ctor to guarantee right initialized instances of this class
122             @descr      -
123 
124             @threadsafe not necessary
125         */
126         QuietInteraction();
127 
128         //_________________________________
129         /**
130             @short      returns the handled interaction request
131             @descr      We saved any getted interaction request internally.
132                         Maybe the outside user of this class is interested
133                         in that. Especially if we got an unknown interaction
134                         and aborted it hard.
135 
136             @return     [com.sun.star.uno.Any]
137                             the packed interaction request
138                             Can be empty if no interaction was used!
139 
140             @threadsafe yes
141         */
142         css::uno::Any getRequest() const;
143 
144         //_________________________________
145         /**
146             @short      returns information if interaction was used
147             @descr      It can be useful to know the reason for a failed operation.
148 
149             @return     [boolean]
150                             <TRUE/> for used interaction
151                             <FALSE/> otherwhise
152 
153             @threadsafe yes
154         */
155         sal_Bool wasUsed() const;
156 };
157 
158 } // namespace framework
159 
160 #endif // #ifndef __FRAMEWORK_INTERACTION_STILLINTERACTION_HXX_
161