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