xref: /aoo41x/main/framework/inc/loadstate.h (revision 228b4580)
1*228b4580SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*228b4580SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*228b4580SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*228b4580SAndrew Rist  * distributed with this work for additional information
6*228b4580SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*228b4580SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*228b4580SAndrew Rist  * "License"); you may not use this file except in compliance
9*228b4580SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*228b4580SAndrew Rist  *
11*228b4580SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*228b4580SAndrew Rist  *
13*228b4580SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*228b4580SAndrew Rist  * software distributed under the License is distributed on an
15*228b4580SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*228b4580SAndrew Rist  * KIND, either express or implied.  See the License for the
17*228b4580SAndrew Rist  * specific language governing permissions and limitations
18*228b4580SAndrew Rist  * under the License.
19*228b4580SAndrew Rist  *
20*228b4580SAndrew Rist  *************************************************************/
21*228b4580SAndrew Rist 
22*228b4580SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_LOADSTATE_H_
25cdf0e10cSrcweir #define __FRAMEWORK_LOADSTATE_H_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir //	includes
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveIOException.hpp>
32cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir //_________________________________________________________________________________________________________________
35cdf0e10cSrcweir //	namespace
36cdf0e10cSrcweir //_________________________________________________________________________________________________________________
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace framework{
39cdf0e10cSrcweir 
40cdf0e10cSrcweir //_______________________________________________________________________
41cdf0e10cSrcweir /**
42cdf0e10cSrcweir     These enum values specify all possible results of a load request.
43cdf0e10cSrcweir     It doesn't matter, if this load operation used dispatch() or loadComponentFromURL().
44cdf0e10cSrcweir     The meaning is everytime the same.
45cdf0e10cSrcweir  */
46cdf0e10cSrcweir enum ELoadState
47cdf0e10cSrcweir {
48cdf0e10cSrcweir     E_UNSPECIFIED   =   0,  // indicates the operation was not already started
49cdf0e10cSrcweir     E_SUCCESS       =   1,  // the load request was successfull
50cdf0e10cSrcweir     E_IOERROR       =   2,  // there was an io error internaly
51cdf0e10cSrcweir     E_INTERACTION   =   3,  // there was an interaction, which couldn't be handled (doesn't include IO interactions => see E_IOERROR before)
52cdf0e10cSrcweir     E_FAILED        =   4   // for unknown or unspecified errors
53cdf0e10cSrcweir };
54cdf0e10cSrcweir 
55cdf0e10cSrcweir //_______________________________________________________________________
56cdf0e10cSrcweir /**
57cdf0e10cSrcweir     Helper, which provides some functionality to identify the reason for
58cdf0e10cSrcweir     a failed load request and can describe it.
59cdf0e10cSrcweir  */
60cdf0e10cSrcweir class LoadStateHelper
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     public:
63cdf0e10cSrcweir 
64cdf0e10cSrcweir         //_________________________________
65cdf0e10cSrcweir         /**
66cdf0e10cSrcweir             @short      checks if the given interaction request was an io error
67cdf0e10cSrcweir             @descr      This information can be used to throw
68cdf0e10cSrcweir                         a suitable IOException. (e.g. loadComponentFromURL())
69cdf0e10cSrcweir 
70cdf0e10cSrcweir             @param      aRequest
71cdf0e10cSrcweir                             the original interaction request, which may produced
72cdf0e10cSrcweir                             the failed load request
73cdf0e10cSrcweir 
74cdf0e10cSrcweir             @param      rReason
75cdf0e10cSrcweir                             in case this Method returns <sal_True/> the referred string object
76cdf0e10cSrcweir                             will be used to set the original message of the
77cdf0e10cSrcweir                             aborted io exception on it.
78cdf0e10cSrcweir                             If method returns <sal_False/> rReason was not used.
79cdf0e10cSrcweir 
80cdf0e10cSrcweir             @return     [boolean]
81cdf0e10cSrcweir                             <sal_True/> in case it was an IO error
82cdf0e10cSrcweir                             <sal_False/> in case it wasn't an IO error or interaction was not used
83cdf0e10cSrcweir         */
wasIOError(const css::uno::Any & aRequest,rtl::OUString & rReason)84cdf0e10cSrcweir         static sal_Bool wasIOError( const css::uno::Any& aRequest ,
85cdf0e10cSrcweir                                           rtl::OUString& rReason  )
86cdf0e10cSrcweir         {
87cdf0e10cSrcweir             if ( ! aRequest.hasValue() )
88cdf0e10cSrcweir                 return sal_False;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir             css::ucb::InteractiveIOException           exIOInteractive ;
91cdf0e10cSrcweir             css::ucb::InteractiveAugmentedIOException  exIOAugmented   ;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir             if (aRequest>>=exIOInteractive)
94cdf0e10cSrcweir             {
95cdf0e10cSrcweir                 rReason = exIOInteractive.Message;
96cdf0e10cSrcweir                 return sal_True;
97cdf0e10cSrcweir             }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir             if (aRequest>>=exIOAugmented)
100cdf0e10cSrcweir             {
101cdf0e10cSrcweir                 rReason = exIOAugmented.Message;
102cdf0e10cSrcweir                 return sal_True;
103cdf0e10cSrcweir             }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir             return sal_False;
106cdf0e10cSrcweir         }
107cdf0e10cSrcweir };
108cdf0e10cSrcweir 
109cdf0e10cSrcweir } // namespace framework
110cdf0e10cSrcweir 
111cdf0e10cSrcweir #endif // #ifndef __FRAMEWORK_LOADSTATE_H_
112