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_LOADENV_LOADENVEXCEPTION_HXX_
25 #define __FRAMEWORK_LOADENV_LOADENVEXCEPTION_HXX_
26 
27 //_______________________________________________
28 // includes of own project
29 
30 //_______________________________________________
31 // includes of uno interface
32 
33 #include <com/sun/star/uno/Any.h>
34 #include <com/sun/star/uno/Exception.hpp>
35 
36 //_______________________________________________
37 // includes of an other project
38 #include <rtl/string.hxx>
39 
40 //_______________________________________________
41 // namespace
42 
43 namespace framework{
44 
45 #ifndef css // conflict with define :-(
46 namespace css = ::com::sun::star;
47 #endif
48 
49 //_______________________________________________
50 // definitions
51 
52 /** @short  specify an exception, which can be used inside the
53             load environment only.
54 
55     @descr  Of course outside code must wrapp it, to transport
56             the occured information to its caller.
57 
58     @author as96863
59  */
60 class LoadEnvException
61 {
62     //___________________________________________
63     // const
64 
65     public:
66 
67         /** @short  Can be used as an ID for an instance of a LoadEnvException.
68             @descr  To prevent errors on adding/removing/changing such IDs here,
69                     an enum field is used. Its int values are self organized ...
70          */
71         enum EIDs
72         {
73             /** @short  The specified URL/Stream/etcpp. can not be handled by a LoadEnv instance. */
74             ID_UNSUPPORTED_CONTENT,
75 
76             /** @short  It was not possible to get access to global filter configuration.
77                 @descr  Might som neccsessary services could not be created. */
78             ID_NO_CONFIG_ACCESS,
79 
80             /** @short  Some data obtained from the filter configuration seems to incorrect.
81                 @descr  Might a filter-type relation ship seem to be damaged. */
82             ID_INVALID_FILTER_CONFIG,
83 
84             /** @short  indicates a corrupted media descriptor.
85                 @descr  Some parts are required - some other ones are optional. Such exception
86                         should be thrown, if a required item does not exists. */
87             ID_INVALID_MEDIADESCRIPTOR,
88 
89             /** @short  Its similar to an uno::RuntimeException ....
90                 @descr  But such runtime exception can break the whole office code.
91                         So its capsulated to this specialized load environment only.
92                         Mostly it indicates a missing but needed resource ... e.g the
93                         global desktop reference! */
94             ID_INVALID_ENVIRONMENT,
95 
96             /** @short  indicates a failed search for the right target frame. */
97             ID_NO_TARGET_FOUND,
98 
99             /** @short  An already existing document was found inside a target frame.
100                         But its controller could not be suspended successfully. Thats
101                         why the new load request was cancelled. The document could not
102                         be replaced. */
103             ID_COULD_NOT_SUSPEND_CONTROLLER,
104 
105             /** @short  TODO */
106             ID_COULD_NOT_REACTIVATE_CONTROLLER,
107 
108             /** @short  inidcates an already running load operation. Of yourse the same
109                         instance cant be used for multiple load requests at the same time.
110              */
111             ID_STILL_RUNNING,
112 
113             /** @short  sometiems we cant specify the reason for an error, because we
114                         was interrupted by an called code in an unexpected way ...
115              */
116             ID_GENERAL_ERROR
117         };
118 
119     //___________________________________________
120     // member
121 
122     public:
123 
124         /** @short  contains a suitable message, which describes the reason for this
125                     exception. */
126         ::rtl::OString m_sMessage;
127 
128         /** @short  An ID, which make this exception unique among others. */
129         sal_Int32 m_nID;
130 
131         /** @short  Contains the original exception, if any occured. */
132         css::uno::Any m_exOriginal;
133 
134         /** TODO
135              Experimental use! May it can be usefully to know, if an exception was already
136              catched and handled by an interaction and was might be rethrowed! */
137         sal_Bool m_bHandled;
138 
139     //___________________________________________
140     // interface
141 
142     public:
143 
144         /** @short  initialize a new instance with an ID.
145             @descr  Some other items of this exception
146                     (e.g. a suitable message) will be generated
147                     automaticly.
148 
149             @param  nID
150                     One of the defined const IDs of this class.
151          */
LoadEnvException(sal_Int32 nID)152         LoadEnvException(sal_Int32 nID)
153         {
154             m_nID = nID;
155         }
156 
157         //_______________________________________
158 
159         /** @short  initialize a new instance with an ID
160                     an wrap a detected exception into this one.
161             @descr  Some other items of this exception
162                     (e.g. a suitable message) will be generated
163                     automaticly.
164 
165             @param  nID
166                     One of the defined const IDs of this class.
167 
168             @param  exUno
169                     the original catched uno exception.
170          */
LoadEnvException(sal_Int32 nID,const css::uno::Any & exUno)171         LoadEnvException(      sal_Int32        nID  ,
172                          const css::uno::Any&   exUno)
173         {
174             m_nID        = nID  ;
175             m_exOriginal = exUno;
176         }
177 
178         //_______________________________________
179 
180         /** @short  destruct an instance of this exception.
181          */
~LoadEnvException()182         ~LoadEnvException()
183         {
184             m_sMessage = ::rtl::OString();
185             m_nID      = 0;
186             m_bHandled = false;
187             m_exOriginal.clear();
188         }
189 };
190 
191 } // namespace framework
192 
193 #endif // __FRAMEWORK_LOADENV_LOADENVEXCEPTION_HXX_
194