xref: /aoo41x/main/desktop/source/app/configinit.hxx (revision 0a1e2f0e)
1*0a1e2f0eSAndrew Rist /**************************************************************
2*0a1e2f0eSAndrew Rist  *
3*0a1e2f0eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*0a1e2f0eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*0a1e2f0eSAndrew Rist  * distributed with this work for additional information
6*0a1e2f0eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*0a1e2f0eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*0a1e2f0eSAndrew Rist  * "License"); you may not use this file except in compliance
9*0a1e2f0eSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*0a1e2f0eSAndrew Rist  *
11*0a1e2f0eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*0a1e2f0eSAndrew Rist  *
13*0a1e2f0eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*0a1e2f0eSAndrew Rist  * software distributed under the License is distributed on an
15*0a1e2f0eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0a1e2f0eSAndrew Rist  * KIND, either express or implied.  See the License for the
17*0a1e2f0eSAndrew Rist  * specific language governing permissions and limitations
18*0a1e2f0eSAndrew Rist  * under the License.
19*0a1e2f0eSAndrew Rist  *
20*0a1e2f0eSAndrew Rist  *************************************************************/
21*0a1e2f0eSAndrew Rist 
22cdf0e10cSrcweir #ifndef _DESKTOP_CONFIGINIT_HXX_
23cdf0e10cSrcweir #define _DESKTOP_CONFIGINIT_HXX_
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26cdf0e10cSrcweir #include <rtl/ustring.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir /** creates a ConfigurationProvider instance
29cdf0e10cSrcweir Important: exceptions thrown from that method will contain a readily
30cdf0e10cSrcweir displayable message.
31cdf0e10cSrcweir 
32cdf0e10cSrcweir     @return
33cdf0e10cSrcweir         The default configuration provider for the application or<br/>
34cdf0e10cSrcweir         <NULL/>, if startup was canceled
35cdf0e10cSrcweir 
36cdf0e10cSrcweir     @throw com::sun::star::configuration::CannotLoadConfigurationException
37cdf0e10cSrcweir         if the configuration provider can't be created
38cdf0e10cSrcweir 
39cdf0e10cSrcweir     @throw com::sun::star::lang::ServiceNotRegisteredException
40cdf0e10cSrcweir         if the ConfigurationProvider service is unknwon
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     @throw com::sun::star::lang::WrappedTargetException
43cdf0e10cSrcweir         if the configuration backend could be created,
44cdf0e10cSrcweir         but incurred a failure later
45cdf0e10cSrcweir 
46cdf0e10cSrcweir */
47cdf0e10cSrcweir extern
48cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
49cdf0e10cSrcweir     CreateApplicationConfigurationProvider( );
50cdf0e10cSrcweir 
51cdf0e10cSrcweir //-----------------------------------------------------------------------------
52cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir /**
55cdf0e10cSrcweir     sets an InteractionHandler for configuration errors in the current context.
56cdf0e10cSrcweir 
57cdf0e10cSrcweir   */
58cdf0e10cSrcweir     class ConfigurationErrorHandler
59cdf0e10cSrcweir     {
60cdf0e10cSrcweir     public:
61cdf0e10cSrcweir         typedef com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > InteractionHandler;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir         /// Constructor: Uses the default interaction handler
ConfigurationErrorHandler()64cdf0e10cSrcweir         ConfigurationErrorHandler()
65cdf0e10cSrcweir         : m_pContext(0), m_xHandler()
66cdf0e10cSrcweir         {}
67cdf0e10cSrcweir 
68cdf0e10cSrcweir         /// Constructor: Uses an externally provided interaction handler
ConfigurationErrorHandler(const InteractionHandler & xHandler)69cdf0e10cSrcweir         ConfigurationErrorHandler(const InteractionHandler & xHandler)
70cdf0e10cSrcweir         : m_pContext(0), m_xHandler( xHandler )
71cdf0e10cSrcweir         {}
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         ~ConfigurationErrorHandler();
74cdf0e10cSrcweir 
75cdf0e10cSrcweir         static InteractionHandler getDefaultInteractionHandler();
76cdf0e10cSrcweir 
77cdf0e10cSrcweir         /// installs the handler into the current context
78cdf0e10cSrcweir         void activate();
79cdf0e10cSrcweir         /// deinstalls the handler from the current context, restoring the previous context
80cdf0e10cSrcweir         void deactivate();
81cdf0e10cSrcweir     private:
82cdf0e10cSrcweir         class Context;
83cdf0e10cSrcweir         Context * m_pContext;
84cdf0e10cSrcweir         InteractionHandler m_xHandler;
85cdf0e10cSrcweir     private:
86cdf0e10cSrcweir         // not implemented - suppress copy
87cdf0e10cSrcweir         ConfigurationErrorHandler(const ConfigurationErrorHandler&);
88cdf0e10cSrcweir         void operator=(const ConfigurationErrorHandler&);
89cdf0e10cSrcweir     };
90cdf0e10cSrcweir 
91cdf0e10cSrcweir //-----------------------------------------------------------------------------
92cdf0e10cSrcweir #endif
93