xref: /AOO41X/main/framework/source/inc/loadenv/loadenvexception.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef __FRAMEWORK_LOADENV_LOADENVEXCEPTION_HXX_
29*cdf0e10cSrcweir #define __FRAMEWORK_LOADENV_LOADENVEXCEPTION_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //_______________________________________________
32*cdf0e10cSrcweir // includes of own project
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir //_______________________________________________
35*cdf0e10cSrcweir // includes of uno interface
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <com/sun/star/uno/Any.h>
38*cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir //_______________________________________________
41*cdf0e10cSrcweir // includes of an other project
42*cdf0e10cSrcweir #include <rtl/string.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir //_______________________________________________
45*cdf0e10cSrcweir // namespace
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir namespace framework{
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir #ifndef css // conflict with define :-(
50*cdf0e10cSrcweir namespace css = ::com::sun::star;
51*cdf0e10cSrcweir #endif
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir //_______________________________________________
54*cdf0e10cSrcweir // definitions
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir /** @short  specify an exception, which can be used inside the
57*cdf0e10cSrcweir             load environment only.
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir     @descr  Of course outside code must wrapp it, to transport
60*cdf0e10cSrcweir             the occured information to its caller.
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     @author as96863
63*cdf0e10cSrcweir  */
64*cdf0e10cSrcweir class LoadEnvException
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir     //___________________________________________
67*cdf0e10cSrcweir     // const
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir     public:
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir         /** @short  Can be used as an ID for an instance of a LoadEnvException.
72*cdf0e10cSrcweir             @descr  To prevent errors on adding/removing/changing such IDs here,
73*cdf0e10cSrcweir                     an enum field is used. Its int values are self organized ...
74*cdf0e10cSrcweir          */
75*cdf0e10cSrcweir         enum EIDs
76*cdf0e10cSrcweir         {
77*cdf0e10cSrcweir             /** @short  The specified URL/Stream/etcpp. can not be handled by a LoadEnv instance. */
78*cdf0e10cSrcweir             ID_UNSUPPORTED_CONTENT,
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir             /** @short  It was not possible to get access to global filter configuration.
81*cdf0e10cSrcweir                 @descr  Might som neccsessary services could not be created. */
82*cdf0e10cSrcweir             ID_NO_CONFIG_ACCESS,
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir             /** @short  Some data obtained from the filter configuration seems to incorrect.
85*cdf0e10cSrcweir                 @descr  Might a filter-type relation ship seem to be damaged. */
86*cdf0e10cSrcweir             ID_INVALID_FILTER_CONFIG,
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir             /** @short  indicates a corrupted media descriptor.
89*cdf0e10cSrcweir                 @descr  Some parts are required - some other ones are optional. Such exception
90*cdf0e10cSrcweir                         should be thrown, if a required item does not exists. */
91*cdf0e10cSrcweir             ID_INVALID_MEDIADESCRIPTOR,
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir             /** @short  Its similar to an uno::RuntimeException ....
94*cdf0e10cSrcweir                 @descr  But such runtime exception can break the whole office code.
95*cdf0e10cSrcweir                         So its capsulated to this specialized load environment only.
96*cdf0e10cSrcweir                         Mostly it indicates a missing but needed resource ... e.g the
97*cdf0e10cSrcweir                         global desktop reference! */
98*cdf0e10cSrcweir             ID_INVALID_ENVIRONMENT,
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir             /** @short  indicates a failed search for the right target frame. */
101*cdf0e10cSrcweir             ID_NO_TARGET_FOUND,
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir             /** @short  An already existing document was found inside a target frame.
104*cdf0e10cSrcweir                         But its controller could not be suspended successfully. Thats
105*cdf0e10cSrcweir                         why the new load request was cancelled. The document could not
106*cdf0e10cSrcweir                         be replaced. */
107*cdf0e10cSrcweir             ID_COULD_NOT_SUSPEND_CONTROLLER,
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir             /** @short  TODO */
110*cdf0e10cSrcweir             ID_COULD_NOT_REACTIVATE_CONTROLLER,
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir             /** @short  inidcates an already running load operation. Of yourse the same
113*cdf0e10cSrcweir                         instance cant be used for multiple load requests at the same time.
114*cdf0e10cSrcweir              */
115*cdf0e10cSrcweir             ID_STILL_RUNNING,
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir             /** @short  sometiems we cant specify the reason for an error, because we
118*cdf0e10cSrcweir                         was interrupted by an called code in an unexpected way ...
119*cdf0e10cSrcweir              */
120*cdf0e10cSrcweir             ID_GENERAL_ERROR
121*cdf0e10cSrcweir         };
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir     //___________________________________________
124*cdf0e10cSrcweir     // member
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir     public:
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir         /** @short  contains a suitable message, which describes the reason for this
129*cdf0e10cSrcweir                     exception. */
130*cdf0e10cSrcweir         ::rtl::OString m_sMessage;
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir         /** @short  An ID, which make this exception unique among others. */
133*cdf0e10cSrcweir         sal_Int32 m_nID;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir         /** @short  Contains the original exception, if any occured. */
136*cdf0e10cSrcweir         css::uno::Any m_exOriginal;
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir         /** TODO
139*cdf0e10cSrcweir              Experimental use! May it can be usefully to know, if an exception was already
140*cdf0e10cSrcweir              catched and handled by an interaction and was might be rethrowed! */
141*cdf0e10cSrcweir         sal_Bool m_bHandled;
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     //___________________________________________
144*cdf0e10cSrcweir     // interface
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     public:
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir         /** @short  initialize a new instance with an ID.
149*cdf0e10cSrcweir             @descr  Some other items of this exception
150*cdf0e10cSrcweir                     (e.g. a suitable message) will be generated
151*cdf0e10cSrcweir                     automaticly.
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir             @param  nID
154*cdf0e10cSrcweir                     One of the defined const IDs of this class.
155*cdf0e10cSrcweir          */
156*cdf0e10cSrcweir         LoadEnvException(sal_Int32 nID)
157*cdf0e10cSrcweir         {
158*cdf0e10cSrcweir             m_nID = nID;
159*cdf0e10cSrcweir         }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir         //_______________________________________
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir         /** @short  initialize a new instance with an ID
164*cdf0e10cSrcweir                     an wrap a detected exception into this one.
165*cdf0e10cSrcweir             @descr  Some other items of this exception
166*cdf0e10cSrcweir                     (e.g. a suitable message) will be generated
167*cdf0e10cSrcweir                     automaticly.
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir             @param  nID
170*cdf0e10cSrcweir                     One of the defined const IDs of this class.
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir             @param  exUno
173*cdf0e10cSrcweir                     the original catched uno exception.
174*cdf0e10cSrcweir          */
175*cdf0e10cSrcweir         LoadEnvException(      sal_Int32        nID  ,
176*cdf0e10cSrcweir                          const css::uno::Any&   exUno)
177*cdf0e10cSrcweir         {
178*cdf0e10cSrcweir             m_nID        = nID  ;
179*cdf0e10cSrcweir             m_exOriginal = exUno;
180*cdf0e10cSrcweir         }
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir         //_______________________________________
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir         /** @short  destruct an instance of this exception.
185*cdf0e10cSrcweir          */
186*cdf0e10cSrcweir         ~LoadEnvException()
187*cdf0e10cSrcweir         {
188*cdf0e10cSrcweir             m_sMessage = ::rtl::OString();
189*cdf0e10cSrcweir             m_nID      = 0;
190*cdf0e10cSrcweir             m_bHandled = false;
191*cdf0e10cSrcweir             m_exOriginal.clear();
192*cdf0e10cSrcweir         }
193*cdf0e10cSrcweir };
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir } // namespace framework
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir #endif // __FRAMEWORK_LOADENV_LOADENVEXCEPTION_HXX_
198