xref: /aoo42x/main/desktop/source/app/configinit.hxx (revision 0a1e2f0e)
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 #ifndef _DESKTOP_CONFIGINIT_HXX_
23 #define _DESKTOP_CONFIGINIT_HXX_
24 
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <rtl/ustring.hxx>
27 
28 /** creates a ConfigurationProvider instance
29 Important: exceptions thrown from that method will contain a readily
30 displayable message.
31 
32     @return
33         The default configuration provider for the application or<br/>
34         <NULL/>, if startup was canceled
35 
36     @throw com::sun::star::configuration::CannotLoadConfigurationException
37         if the configuration provider can't be created
38 
39     @throw com::sun::star::lang::ServiceNotRegisteredException
40         if the ConfigurationProvider service is unknwon
41 
42     @throw com::sun::star::lang::WrappedTargetException
43         if the configuration backend could be created,
44         but incurred a failure later
45 
46 */
47 extern
48 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
49     CreateApplicationConfigurationProvider( );
50 
51 //-----------------------------------------------------------------------------
52 #include <com/sun/star/task/XInteractionHandler.hpp>
53 
54 /**
55     sets an InteractionHandler for configuration errors in the current context.
56 
57   */
58     class ConfigurationErrorHandler
59     {
60     public:
61         typedef com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > InteractionHandler;
62 
63         /// Constructor: Uses the default interaction handler
ConfigurationErrorHandler()64         ConfigurationErrorHandler()
65         : m_pContext(0), m_xHandler()
66         {}
67 
68         /// Constructor: Uses an externally provided interaction handler
ConfigurationErrorHandler(const InteractionHandler & xHandler)69         ConfigurationErrorHandler(const InteractionHandler & xHandler)
70         : m_pContext(0), m_xHandler( xHandler )
71         {}
72 
73         ~ConfigurationErrorHandler();
74 
75         static InteractionHandler getDefaultInteractionHandler();
76 
77         /// installs the handler into the current context
78         void activate();
79         /// deinstalls the handler from the current context, restoring the previous context
80         void deactivate();
81     private:
82         class Context;
83         Context * m_pContext;
84         InteractionHandler m_xHandler;
85     private:
86         // not implemented - suppress copy
87         ConfigurationErrorHandler(const ConfigurationErrorHandler&);
88         void operator=(const ConfigurationErrorHandler&);
89     };
90 
91 //-----------------------------------------------------------------------------
92 #endif
93