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 #ifndef _CPPUHELPER_BOOTSTRAP_HXX_ 24 #define _CPPUHELPER_BOOTSTRAP_HXX_ 25 26 #include "sal/config.h" 27 #include "com/sun/star/uno/Exception.hpp" 28 #include "com/sun/star/uno/Reference.hxx" 29 #include "rtl/ustring.hxx" 30 #include "sal/types.h" 31 32 #include "cppuhelper/cppuhelperdllapi.h" 33 34 namespace com { namespace sun { namespace star { 35 namespace container { class XHierarchicalNameAccess; } 36 namespace registry { class XSimpleRegistry; } 37 namespace uno { class XComponentContext; } 38 } } } 39 40 namespace cppu 41 { 42 43 /** Creates a simple registry service instance. 44 45 @rBootstrapPath optional bootstrap path for initial components 46 @return simple registry service instance 47 */ 48 CPPUHELPER_DLLPUBLIC 49 ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry > 50 SAL_CALL createSimpleRegistry( 51 const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() ) 52 SAL_THROW( () ); 53 54 /** Creates a nested registry service instance. 55 56 @rBootstrapPath optional bootstrap path for initial components 57 @return nested registry service instance 58 */ 59 CPPUHELPER_DLLPUBLIC 60 ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry > 61 SAL_CALL createNestedRegistry( 62 const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() ) 63 SAL_THROW( () ); 64 65 /** Installs type description manager instance, i.e. registers a callback at cppu core. 66 67 @param xTDMgr manager instance 68 @return true, if successfully registered 69 */ 70 CPPUHELPER_DLLPUBLIC 71 sal_Bool SAL_CALL installTypeDescriptionManager( 72 ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess > const & xTDMgr ) 73 SAL_THROW( () ); 74 75 /** Bootstraps an initial component context with service manager upon a given registry. 76 This includes insertion of initial services: 77 - (registry) service manager, shared lib loader, 78 - simple registry, nested registry, 79 - implementation registration 80 - registry typedescription provider, typedescription manager (also installs it into cppu core) 81 82 @param xRegistry registry for service manager and singleton objects of context (may be null) 83 @param rBootstrapPath optional bootstrap path for initial components 84 @return component context 85 */ 86 CPPUHELPER_DLLPUBLIC 87 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL 88 bootstrap_InitialComponentContext( 89 ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry > const & xRegistry, 90 ::rtl::OUString const & rBootstrapPath = ::rtl::OUString() ); 91 92 93 /** Bootstraps an initial component context with service manager upon default types and 94 services registry. 95 This includes insertion of initial services: 96 - (registry) service manager, shared lib loader, 97 - simple registry, nested registry, 98 - implementation registration 99 - registry typedescription provider, typedescription manager (also installs it into cppu core) 100 101 This function tries to find its parameters via these bootstrap variables: 102 103 - UNO_TYPES -- a space separated list of file urls of type rdbs 104 - UNO_SERVICES -- a space separated list of file urls of service rdbs 105 - UNO_WRITERDB -- a file url of a write rdb (e.g. user.rdb) 106 107 Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html 108 for further info. 109 110 @return component context 111 */ 112 CPPUHELPER_DLLPUBLIC 113 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL 114 defaultBootstrap_InitialComponentContext(); 115 116 117 /** Bootstraps an initial component context with service manager upon default types and 118 services registry. 119 This includes insertion of initial services: 120 - (registry) service manager, shared lib loader, 121 - simple registry, nested registry, 122 - implementation registration 123 - registry typedescription provider, typedescription manager (also installs it into cppu core) 124 125 This function tries to find its parameters via these bootstrap variables: 126 127 - UNO_TYPES -- a space separated list of file urls of type rdbs 128 - UNO_SERVICES -- a space separated list of file urls of service rdbs 129 - UNO_WRITERDB -- a file url of a write rdb (e.g. user.rdb) 130 131 Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html 132 for further info. 133 134 @param iniFile ini filename to get bootstrap variables 135 @return component context 136 */ 137 CPPUHELPER_DLLPUBLIC 138 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL 139 defaultBootstrap_InitialComponentContext(const ::rtl::OUString & iniFile); 140 141 /** 142 * An exception indicating a bootstrap error. 143 * 144 * @since UDK 3.2.0 145 */ 146 class CPPUHELPER_DLLPUBLIC BootstrapException 147 { 148 public: 149 /** 150 * Constructs a BootstrapException. 151 */ 152 BootstrapException(); 153 154 /** 155 * Constructs a BootstrapException with the specified detail message. 156 * 157 * @param rMessage 158 * A message containing any details about the exception. 159 */ 160 BootstrapException( const ::rtl::OUString & rMessage ); 161 162 /** 163 * Copy constructs a BootstrapException. 164 */ 165 BootstrapException( const BootstrapException & e ); 166 167 /** 168 * Destructs a BootstrapException. 169 */ 170 virtual ~BootstrapException(); 171 172 /** 173 * Assigns a BootstrapException. 174 */ 175 BootstrapException & operator=( const BootstrapException & e ); 176 177 /** Gets the message. 178 179 @return 180 A reference to the message. The reference is valid for the lifetime of 181 this BootstrapException. 182 */ 183 const ::rtl::OUString & getMessage() const; 184 185 private: 186 ::rtl::OUString m_aMessage; 187 }; 188 189 /** 190 * Bootstraps the component context from a UNO installation. 191 * 192 * @return a bootstrapped component context 193 * @exception BootstrapException 194 * Thrown in case bootstrap() signals an exception due to a 195 * bootstrap error. 196 * 197 * @since UDK 3.2.0 198 */ 199 CPPUHELPER_DLLPUBLIC 200 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > 201 SAL_CALL bootstrap(); 202 203 /** 204 * Helper function to expand vnd.sun.star.expand URLs in contexts where no 205 * properly bootstrapped UNO is (yet) available. 206 * 207 * @internal 208 * 209 * @param uri 210 * Some URI (but not a URI reference). 211 * 212 * @return 213 * If uri is a vnd.sun.star.expand URL, then the expansion of that URL is 214 * returned; expansion may lead to a string that is not a legal URI. Otherwise, 215 * the uri is returned unchanged. 216 * 217 * @exception com::sun::star::lang::IllegalArgumentException 218 * If uri is a vnd.sun.star.expand URL that contains unknown macros. 219 * 220 * @since UDK 3.2.8 221 */ 222 CPPUHELPER_DLLPUBLIC 223 ::rtl::OUString 224 SAL_CALL bootstrap_expandUri(::rtl::OUString const & uri); 225 226 } // end namespace cppu 227 228 #endif 229