| File: | cppuhelper/source/defaultbootstrap.cxx |
| Location: | line 1919, column 24 |
| Description: | Called C++ object pointer is null |
| 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | /* |
| 3 | * Version: MPL 1.1 / GPLv3+ / LGPLv3+ |
| 4 | * |
| 5 | * The contents of this file are subject to the Mozilla Public License Version |
| 6 | * 1.1 (the "License"); you may not use this file except in compliance with |
| 7 | * the License or as specified alternatively below. You may obtain a copy of |
| 8 | * the License at http://www.mozilla.org/MPL/ |
| 9 | * |
| 10 | * Software distributed under the License is distributed on an "AS IS" basis, |
| 11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 12 | * for the specific language governing rights and limitations under the |
| 13 | * License. |
| 14 | * |
| 15 | * Major Contributor(s): |
| 16 | * [ Copyright (C) 2012 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com> |
| 17 | * (initial developer) ] |
| 18 | * |
| 19 | * All Rights Reserved. |
| 20 | * |
| 21 | * For minor contributions see the git repository. |
| 22 | * |
| 23 | * Alternatively, the contents of this file may be used under the terms of |
| 24 | * either the GNU General Public License Version 3 or later (the "GPLv3+"), or |
| 25 | * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), |
| 26 | * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable |
| 27 | * instead of those above. |
| 28 | */ |
| 29 | |
| 30 | #include "sal/config.h" |
| 31 | |
| 32 | #include <algorithm> |
| 33 | #include <cassert> |
| 34 | #include <cstring> |
| 35 | #include <map> |
| 36 | #include <vector> |
| 37 | |
| 38 | #include "boost/noncopyable.hpp" |
| 39 | #include "boost/shared_ptr.hpp" |
| 40 | #include "com/sun/star/beans/NamedValue.hpp" |
| 41 | #include "com/sun/star/beans/PropertyAttribute.hpp" |
| 42 | #include "com/sun/star/beans/XPropertySet.hpp" |
| 43 | #include "com/sun/star/container/ElementExistException.hpp" |
| 44 | #include "com/sun/star/container/XContentEnumerationAccess.hpp" |
| 45 | #include "com/sun/star/container/XEnumeration.hpp" |
| 46 | #include "com/sun/star/container/XHierarchicalNameAccess.hpp" |
| 47 | #include "com/sun/star/container/XNameContainer.hpp" |
| 48 | #include "com/sun/star/container/XSet.hpp" |
| 49 | #include "com/sun/star/lang/XInitialization.hpp" |
| 50 | #include "com/sun/star/lang/XServiceInfo.hpp" |
| 51 | #include "com/sun/star/lang/XSingleComponentFactory.hpp" |
| 52 | #include "com/sun/star/lang/XSingleServiceFactory.hpp" |
| 53 | #include "com/sun/star/loader/XImplementationLoader.hpp" |
| 54 | #include "com/sun/star/registry/InvalidRegistryException.hpp" |
| 55 | #include "com/sun/star/registry/XSimpleRegistry.hpp" |
| 56 | #include "com/sun/star/uno/DeploymentException.hpp" |
| 57 | #include "com/sun/star/uno/Reference.hxx" |
| 58 | #include "com/sun/star/uno/XComponentContext.hpp" |
| 59 | #include "cppuhelper/bootstrap.hxx" |
| 60 | #include "cppuhelper/compbase8.hxx" |
| 61 | #include "cppuhelper/component_context.hxx" |
| 62 | #include "cppuhelper/implbase1.hxx" |
| 63 | #include "cppuhelper/implbase3.hxx" |
| 64 | #include "cppuhelper/shlib.hxx" |
| 65 | #include "osl/file.hxx" |
| 66 | #include "registry/registry.hxx" |
| 67 | #include "rtl/bootstrap.hxx" |
| 68 | #include "rtl/ref.hxx" |
| 69 | #include "rtl/uri.hxx" |
| 70 | #include "rtl/ustring.hxx" |
| 71 | #include "xmlreader/xmlreader.hxx" |
| 72 | |
| 73 | #include "macro_expander.hxx" |
| 74 | #include "paths.hxx" |
| 75 | #include "servicefactory_detail.hxx" |
| 76 | |
| 77 | namespace { |
| 78 | |
| 79 | namespace css = com::sun::star; |
| 80 | |
| 81 | bool nextDirectoryItem(osl::Directory & directory, rtl::OUString * url) { |
| 82 | assert(url != 0)((url != 0) ? static_cast<void> (0) : __assert_fail ("url != 0" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 82, __PRETTY_FUNCTION__)); |
| 83 | for (;;) { |
| 84 | osl::DirectoryItem i; |
| 85 | switch (directory.getNextItem(i, SAL_MAX_UINT32((sal_uInt32) 0xFFFFFFFF))) { |
| 86 | case osl::FileBase::E_None: |
| 87 | break; |
| 88 | case osl::FileBase::E_NOENT: |
| 89 | return false; |
| 90 | default: |
| 91 | throw css::uno::DeploymentException( |
| 92 | "Cannot iterate directory", |
| 93 | css::uno::Reference< css::uno::XInterface >()); |
| 94 | } |
| 95 | osl::FileStatus stat( |
| 96 | osl_FileStatus_Mask_Type0x00000001 | osl_FileStatus_Mask_FileName0x00000100 | |
| 97 | osl_FileStatus_Mask_FileURL0x00000200); |
| 98 | if (i.getFileStatus(stat) != osl::FileBase::E_None) { |
| 99 | throw css::uno::DeploymentException( |
| 100 | "Cannot stat in directory", |
| 101 | css::uno::Reference< css::uno::XInterface >()); |
| 102 | } |
| 103 | if (stat.getFileType() != osl::FileStatus::Directory) { //TODO: symlinks |
| 104 | // Ignore backup files: |
| 105 | rtl::OUString name(stat.getFileName()); |
| 106 | if (!(name.match(".") || name.endsWith("~"))) { |
| 107 | *url = stat.getFileURL(); |
| 108 | return true; |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | void decodeRdbUri(rtl::OUString * uri, bool * optional, bool * directory) { |
| 115 | assert(uri != 0 && optional != 0 && directory != 0)((uri != 0 && optional != 0 && directory != 0 ) ? static_cast<void> (0) : __assert_fail ("uri != 0 && optional != 0 && directory != 0" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 115, __PRETTY_FUNCTION__)); |
| 116 | *optional = (*uri)[0] == '?'; |
| 117 | if (*optional) { |
| 118 | *uri = uri->copy(1); |
| 119 | } |
| 120 | *directory = uri->getLength() >= 3 && (*uri)[0] == '<' |
| 121 | && (*uri)[uri->getLength() - 2] == '>' |
| 122 | && (*uri)[uri->getLength() - 1] == '*'; |
| 123 | if (*directory) { |
| 124 | *uri = uri->copy(1, uri->getLength() - 3); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | struct ImplementationInfo: private boost::noncopyable { |
| 129 | ImplementationInfo( |
| 130 | rtl::OUString const & theName, rtl::OUString const & theLoader, |
| 131 | rtl::OUString const & theUri, rtl::OUString const & thePrefix, |
| 132 | css::uno::Reference< css::uno::XComponentContext > const & |
| 133 | theAlienContext): |
| 134 | name(theName), loader(theLoader), uri(theUri), prefix(thePrefix), |
| 135 | alienContext(theAlienContext) |
| 136 | {} |
| 137 | |
| 138 | explicit ImplementationInfo(rtl::OUString const & theName): name(theName) {} |
| 139 | |
| 140 | rtl::OUString const name; |
| 141 | rtl::OUString const loader; |
| 142 | rtl::OUString const uri; |
| 143 | rtl::OUString const prefix; |
| 144 | css::uno::Reference< css::uno::XComponentContext > const alienContext; |
| 145 | std::vector< rtl::OUString > services; |
| 146 | std::vector< rtl::OUString > singletons; |
| 147 | }; |
| 148 | |
| 149 | struct Implementation: private boost::noncopyable { |
| 150 | Implementation( |
| 151 | rtl::OUString const & name, rtl::OUString const & loader, |
| 152 | rtl::OUString const & uri, |
| 153 | rtl::OUString const & prefix = rtl::OUString(), |
| 154 | css::uno::Reference< css::uno::XComponentContext > const & |
| 155 | alienContext |
| 156 | = css::uno::Reference< css::uno::XComponentContext >()): |
| 157 | info(new ImplementationInfo(name, loader, uri, prefix, alienContext)), |
| 158 | loaded(false) |
| 159 | {} |
| 160 | |
| 161 | Implementation( |
| 162 | rtl::OUString const & name, |
| 163 | css::uno::Reference< css::lang::XSingleComponentFactory > const & |
| 164 | theFactory1, |
| 165 | css::uno::Reference< css::lang::XSingleServiceFactory > const & |
| 166 | theFactory2, |
| 167 | css::uno::Reference< css::lang::XComponent > const & theComponent): |
| 168 | info(new ImplementationInfo(name)), factory1(theFactory1), |
| 169 | factory2(theFactory2), component(theComponent), loaded(true) |
| 170 | {} |
| 171 | |
| 172 | boost::shared_ptr< ImplementationInfo > info; |
| 173 | css::uno::Reference< css::lang::XSingleComponentFactory > factory1; |
| 174 | css::uno::Reference< css::lang::XSingleServiceFactory > factory2; |
| 175 | css::uno::Reference< css::lang::XComponent > component; |
| 176 | bool loaded; |
| 177 | }; |
| 178 | |
| 179 | typedef std::map< rtl::OUString, boost::shared_ptr< Implementation > > |
| 180 | NamedImplementations; |
| 181 | |
| 182 | typedef |
| 183 | std::map< |
| 184 | css::uno::Reference< css::lang::XServiceInfo >, |
| 185 | boost::shared_ptr< Implementation > > |
| 186 | DynamicImplementations; |
| 187 | |
| 188 | typedef |
| 189 | std::map< |
| 190 | rtl::OUString, std::vector< boost::shared_ptr< Implementation > > > |
| 191 | ImplementationMap; |
| 192 | |
| 193 | void insertImplementationMap( |
| 194 | ImplementationMap * destination, ImplementationMap const & source) |
| 195 | { |
| 196 | assert(destination != 0)((destination != 0) ? static_cast<void> (0) : __assert_fail ("destination != 0", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 196, __PRETTY_FUNCTION__)); |
| 197 | for (ImplementationMap::const_iterator i(source.begin()); i != source.end(); |
| 198 | ++i) |
| 199 | { |
| 200 | std::vector< boost::shared_ptr< Implementation > > & impls |
| 201 | = (*destination)[i->first]; |
| 202 | impls.insert(impls.end(), i->second.begin(), i->second.end()); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | void removeFromImplementationMap( |
| 207 | ImplementationMap * map, std::vector< rtl::OUString > const & elements, |
| 208 | boost::shared_ptr< Implementation > const & implementation) |
| 209 | { |
| 210 | // The underlying data structures make this function somewhat inefficient, |
| 211 | // but the assumption is that it is rarely called: |
| 212 | assert(map != 0)((map != 0) ? static_cast<void> (0) : __assert_fail ("map != 0" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 212, __PRETTY_FUNCTION__)); |
| 213 | for (std::vector< rtl::OUString >::const_iterator i(elements.begin()); |
| 214 | i != elements.end(); ++i) |
| 215 | { |
| 216 | ImplementationMap::iterator j(map->find(*i)); |
| 217 | assert(j != map->end())((j != map->end()) ? static_cast<void> (0) : __assert_fail ("j != map->end()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 217, __PRETTY_FUNCTION__)); |
| 218 | std::vector< boost::shared_ptr< Implementation > >::iterator k( |
| 219 | std::find(j->second.begin(), j->second.end(), implementation)); |
| 220 | assert(k != j->second.end())((k != j->second.end()) ? static_cast<void> (0) : __assert_fail ("k != j->second.end()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 220, __PRETTY_FUNCTION__)); |
| 221 | j->second.erase(k); |
| 222 | if (j->second.empty()) { |
| 223 | map->erase(j); |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | struct Data: private boost::noncopyable { |
| 229 | NamedImplementations namedImplementations; |
| 230 | DynamicImplementations dynamicImplementations; |
| 231 | ImplementationMap services; |
| 232 | ImplementationMap singletons; |
| 233 | }; |
| 234 | |
| 235 | // This is largely a copy from stoc/source/simpleregistry/textualservices.cxx |
| 236 | // (which it obsoletes); cppuhelper's published interface concept makes it |
| 237 | // difficult to make both places use a shared Parser implementation, so I |
| 238 | // created a copy for now (until the whole stoc/source/simpleregistry stuff can |
| 239 | // be removed in an incompatible LibreOffice version). For simplicity, this |
| 240 | // code keeps throwing css::registry::InvalidRegistryException for invalid XML |
| 241 | // rdbs (even though that does not fit the exception's name): |
| 242 | class Parser: private boost::noncopyable { |
| 243 | public: |
| 244 | Parser( |
| 245 | rtl::OUString const & uri, |
| 246 | css::uno::Reference< css::uno::XComponentContext > const & alienContext, |
| 247 | Data * data); |
| 248 | |
| 249 | private: |
| 250 | void handleComponent(); |
| 251 | |
| 252 | void handleImplementation(); |
| 253 | |
| 254 | void handleService(); |
| 255 | |
| 256 | void handleSingleton(); |
| 257 | |
| 258 | rtl::OUString getNameAttribute(); |
| 259 | |
| 260 | xmlreader::XmlReader reader_; |
| 261 | css::uno::Reference< css::uno::XComponentContext > alienContext_; |
| 262 | Data * data_; |
| 263 | rtl::OUString attrLoader_; |
| 264 | rtl::OUString attrUri_; |
| 265 | rtl::OUString attrPrefix_; |
| 266 | rtl::OUString attrImplementation_; |
| 267 | boost::shared_ptr< Implementation > implementation_; |
| 268 | }; |
| 269 | |
| 270 | Parser::Parser( |
| 271 | rtl::OUString const & uri, |
| 272 | css::uno::Reference< css::uno::XComponentContext > const & alienContext, |
| 273 | Data * data): |
| 274 | reader_(uri), alienContext_(alienContext), data_(data) |
| 275 | { |
| 276 | assert(data != 0)((data != 0) ? static_cast<void> (0) : __assert_fail ("data != 0" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 276, __PRETTY_FUNCTION__)); |
| 277 | int ucNsId = reader_.registerNamespaceIri( |
| 278 | xmlreader::Span( |
| 279 | RTL_CONSTASCII_STRINGPARAM((&("http://openoffice.org/2010/uno-components")[0]), ((sal_Int32 )(sizeof ("http://openoffice.org/2010/uno-components") / sizeof (("http://openoffice.org/2010/uno-components")[0]))-1) |
| 280 | "http://openoffice.org/2010/uno-components")(&("http://openoffice.org/2010/uno-components")[0]), ((sal_Int32 )(sizeof ("http://openoffice.org/2010/uno-components") / sizeof (("http://openoffice.org/2010/uno-components")[0]))-1))); |
| 281 | enum State { |
| 282 | STATE_BEGIN, STATE_END, STATE_COMPONENTS, STATE_COMPONENT_INITIAL, |
| 283 | STATE_COMPONENT, STATE_IMPLEMENTATION, STATE_SERVICE, STATE_SINGLETON }; |
| 284 | for (State state = STATE_BEGIN;;) { |
| 285 | xmlreader::Span name; |
| 286 | int nsId; |
| 287 | xmlreader::XmlReader::Result res = reader_.nextItem( |
| 288 | xmlreader::XmlReader::TEXT_NONE, &name, &nsId); |
| 289 | switch (state) { |
| 290 | case STATE_BEGIN: |
| 291 | if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId |
| 292 | && name.equals(RTL_CONSTASCII_STRINGPARAM("components")(&("components")[0]), ((sal_Int32)(sizeof ("components") / sizeof (("components")[0]))-1))) |
| 293 | { |
| 294 | state = STATE_COMPONENTS; |
| 295 | break; |
| 296 | } |
| 297 | throw css::registry::InvalidRegistryException( |
| 298 | reader_.getUrl() + ": unexpected item in outer level", |
| 299 | css::uno::Reference< css::uno::XInterface >()); |
| 300 | case STATE_END: |
| 301 | if (res == xmlreader::XmlReader::RESULT_DONE) { |
| 302 | return; |
| 303 | } |
| 304 | throw css::registry::InvalidRegistryException( |
| 305 | reader_.getUrl() + ": unexpected item in outer level", |
| 306 | css::uno::Reference< css::uno::XInterface >()); |
| 307 | case STATE_COMPONENTS: |
| 308 | if (res == xmlreader::XmlReader::RESULT_END) { |
| 309 | state = STATE_END; |
| 310 | break; |
| 311 | } |
| 312 | if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId |
| 313 | && name.equals(RTL_CONSTASCII_STRINGPARAM("component")(&("component")[0]), ((sal_Int32)(sizeof ("component") / sizeof (("component")[0]))-1))) |
| 314 | { |
| 315 | handleComponent(); |
| 316 | state = STATE_COMPONENT_INITIAL; |
| 317 | break; |
| 318 | } |
| 319 | throw css::registry::InvalidRegistryException( |
| 320 | reader_.getUrl() + ": unexpected item in <components>", |
| 321 | css::uno::Reference< css::uno::XInterface >()); |
| 322 | case STATE_COMPONENT: |
| 323 | if (res == xmlreader::XmlReader::RESULT_END) { |
| 324 | state = STATE_COMPONENTS; |
| 325 | break; |
| 326 | } |
| 327 | // fall through |
| 328 | case STATE_COMPONENT_INITIAL: |
| 329 | if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId |
| 330 | && name.equals(RTL_CONSTASCII_STRINGPARAM("implementation")(&("implementation")[0]), ((sal_Int32)(sizeof ("implementation" ) / sizeof (("implementation")[0]))-1))) |
| 331 | { |
| 332 | handleImplementation(); |
| 333 | state = STATE_IMPLEMENTATION; |
| 334 | break; |
| 335 | } |
| 336 | throw css::registry::InvalidRegistryException( |
| 337 | reader_.getUrl() + ": unexpected item in <component>", |
| 338 | css::uno::Reference< css::uno::XInterface >()); |
| 339 | case STATE_IMPLEMENTATION: |
| 340 | if (res == xmlreader::XmlReader::RESULT_END) { |
| 341 | state = STATE_COMPONENT; |
| 342 | break; |
| 343 | } |
| 344 | if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId |
| 345 | && name.equals(RTL_CONSTASCII_STRINGPARAM("service")(&("service")[0]), ((sal_Int32)(sizeof ("service") / sizeof (("service")[0]))-1))) |
| 346 | { |
| 347 | handleService(); |
| 348 | state = STATE_SERVICE; |
| 349 | break; |
| 350 | } |
| 351 | if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId |
| 352 | && name.equals(RTL_CONSTASCII_STRINGPARAM("singleton")(&("singleton")[0]), ((sal_Int32)(sizeof ("singleton") / sizeof (("singleton")[0]))-1))) |
| 353 | { |
| 354 | handleSingleton(); |
| 355 | state = STATE_SINGLETON; |
| 356 | break; |
| 357 | } |
| 358 | throw css::registry::InvalidRegistryException( |
| 359 | reader_.getUrl() + ": unexpected item in <implementation>", |
| 360 | css::uno::Reference< css::uno::XInterface >()); |
| 361 | case STATE_SERVICE: |
| 362 | if (res == xmlreader::XmlReader::RESULT_END) { |
| 363 | state = STATE_IMPLEMENTATION; |
| 364 | break; |
| 365 | } |
| 366 | throw css::registry::InvalidRegistryException( |
| 367 | reader_.getUrl() + ": unexpected item in <service>", |
| 368 | css::uno::Reference< css::uno::XInterface >()); |
| 369 | case STATE_SINGLETON: |
| 370 | if (res == xmlreader::XmlReader::RESULT_END) { |
| 371 | state = STATE_IMPLEMENTATION; |
| 372 | break; |
| 373 | } |
| 374 | throw css::registry::InvalidRegistryException( |
| 375 | reader_.getUrl() + ": unexpected item in <service>", |
| 376 | css::uno::Reference< css::uno::XInterface >()); |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | void Parser::handleComponent() { |
| 382 | attrLoader_ = rtl::OUString(); |
| 383 | attrUri_ = rtl::OUString(); |
| 384 | attrPrefix_ = rtl::OUString(); |
| 385 | xmlreader::Span name; |
| 386 | int nsId; |
| 387 | while (reader_.nextAttribute(&nsId, &name)) { |
| 388 | if (nsId == xmlreader::XmlReader::NAMESPACE_NONE |
| 389 | && name.equals(RTL_CONSTASCII_STRINGPARAM("loader")(&("loader")[0]), ((sal_Int32)(sizeof ("loader") / sizeof (("loader")[0]))-1))) |
| 390 | { |
| 391 | if (!attrLoader_.isEmpty()) { |
| 392 | throw css::registry::InvalidRegistryException( |
| 393 | (reader_.getUrl() |
| 394 | + ": <component> has multiple \"loader\" attributes"), |
| 395 | css::uno::Reference< css::uno::XInterface >()); |
| 396 | } |
| 397 | attrLoader_ = reader_.getAttributeValue(false).convertFromUtf8(); |
| 398 | if (attrLoader_.isEmpty()) { |
| 399 | throw css::registry::InvalidRegistryException( |
| 400 | (reader_.getUrl() |
| 401 | + ": <component> has empty \"loader\" attribute"), |
| 402 | css::uno::Reference< css::uno::XInterface >()); |
| 403 | } |
| 404 | } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE |
| 405 | && name.equals(RTL_CONSTASCII_STRINGPARAM("uri")(&("uri")[0]), ((sal_Int32)(sizeof ("uri") / sizeof (("uri" )[0]))-1))) |
| 406 | { |
| 407 | if (!attrUri_.isEmpty()) { |
| 408 | throw css::registry::InvalidRegistryException( |
| 409 | (reader_.getUrl() |
| 410 | + ": <component> has multiple \"uri\" attributes"), |
| 411 | css::uno::Reference< css::uno::XInterface >()); |
| 412 | } |
| 413 | attrUri_ = reader_.getAttributeValue(false).convertFromUtf8(); |
| 414 | if (attrUri_.isEmpty()) { |
| 415 | throw css::registry::InvalidRegistryException( |
| 416 | (reader_.getUrl() |
| 417 | + ": <component> has empty \"uri\" attribute"), |
| 418 | css::uno::Reference< css::uno::XInterface >()); |
| 419 | } |
| 420 | } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE |
| 421 | && name.equals(RTL_CONSTASCII_STRINGPARAM("prefix")(&("prefix")[0]), ((sal_Int32)(sizeof ("prefix") / sizeof (("prefix")[0]))-1))) |
| 422 | { |
| 423 | if (!attrPrefix_.isEmpty()) { |
| 424 | throw css::registry::InvalidRegistryException( |
| 425 | (reader_.getUrl() + |
| 426 | ": <component> has multiple \"prefix\" attributes"), |
| 427 | css::uno::Reference< css::uno::XInterface >()); |
| 428 | } |
| 429 | attrPrefix_ = reader_.getAttributeValue(false).convertFromUtf8(); |
| 430 | if (attrPrefix_.isEmpty()) { |
| 431 | throw css::registry::InvalidRegistryException( |
| 432 | (reader_.getUrl() + |
| 433 | ": <component> has empty \"prefix\" attribute"), |
| 434 | css::uno::Reference< css::uno::XInterface >()); |
| 435 | } |
| 436 | } else { |
| 437 | throw css::registry::InvalidRegistryException( |
| 438 | (reader_.getUrl() + ": unexpected attribute \"" |
| 439 | + name.convertFromUtf8() + "\" in <component>"), |
| 440 | css::uno::Reference< css::uno::XInterface >()); |
| 441 | } |
| 442 | } |
| 443 | if (attrLoader_.isEmpty()) { |
| 444 | throw css::registry::InvalidRegistryException( |
| 445 | reader_.getUrl() + ": <component> is missing \"loader\" attribute", |
| 446 | css::uno::Reference< css::uno::XInterface >()); |
| 447 | } |
| 448 | if (attrUri_.isEmpty()) { |
| 449 | throw css::registry::InvalidRegistryException( |
| 450 | reader_.getUrl() + ": <component> is missing \"uri\" attribute", |
| 451 | css::uno::Reference< css::uno::XInterface >()); |
| 452 | } |
| 453 | #ifndef DISABLE_DYNLOADING |
| 454 | try { |
| 455 | attrUri_ = rtl::Uri::convertRelToAbs(reader_.getUrl(), attrUri_); |
| 456 | } catch (const rtl::MalformedUriException & e) { |
| 457 | throw css::registry::InvalidRegistryException( |
| 458 | reader_.getUrl() + ": bad \"uri\" attribute: " + e.getMessage(), |
| 459 | css::uno::Reference< css::uno::XInterface >()); |
| 460 | } |
| 461 | #endif |
| 462 | } |
| 463 | |
| 464 | void Parser::handleImplementation() { |
| 465 | attrImplementation_ = getNameAttribute(); |
| 466 | implementation_.reset( |
| 467 | new Implementation( |
| 468 | attrImplementation_, attrLoader_, attrUri_, attrPrefix_, |
| 469 | alienContext_)); |
| 470 | if (!data_->namedImplementations.insert( |
| 471 | NamedImplementations::value_type( |
| 472 | attrImplementation_, implementation_)). |
| 473 | second) |
| 474 | { |
| 475 | throw css::registry::InvalidRegistryException( |
| 476 | (reader_.getUrl() + ": duplicate <implementation name=\"" |
| 477 | + attrImplementation_ + "\">"), |
| 478 | css::uno::Reference< css::uno::XInterface >()); |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | void Parser::handleService() { |
| 483 | rtl::OUString name(getNameAttribute()); |
| 484 | implementation_->info->services.push_back(name); |
| 485 | data_->services[name].push_back(implementation_); |
| 486 | } |
| 487 | |
| 488 | void Parser::handleSingleton() { |
| 489 | rtl::OUString name(getNameAttribute()); |
| 490 | implementation_->info->singletons.push_back(name); |
| 491 | data_->singletons[name].push_back(implementation_); |
| 492 | } |
| 493 | |
| 494 | rtl::OUString Parser::getNameAttribute() { |
| 495 | rtl::OUString attrName; |
| 496 | xmlreader::Span name; |
| 497 | int nsId; |
| 498 | while (reader_.nextAttribute(&nsId, &name)) { |
| 499 | if (nsId == xmlreader::XmlReader::NAMESPACE_NONE |
| 500 | && name.equals(RTL_CONSTASCII_STRINGPARAM("name")(&("name")[0]), ((sal_Int32)(sizeof ("name") / sizeof (("name" )[0]))-1))) |
| 501 | { |
| 502 | if (!attrName.isEmpty()) { |
| 503 | throw css::registry::InvalidRegistryException( |
| 504 | (reader_.getUrl() |
| 505 | + ": element has multiple \"name\" attributes"), |
| 506 | css::uno::Reference< css::uno::XInterface >()); |
| 507 | } |
| 508 | attrName = reader_.getAttributeValue(false).convertFromUtf8(); |
| 509 | if (attrName.isEmpty()) { |
| 510 | throw css::registry::InvalidRegistryException( |
| 511 | reader_.getUrl() + ": element has empty \"name\" attribute", |
| 512 | css::uno::Reference< css::uno::XInterface >()); |
| 513 | } |
| 514 | } else { |
| 515 | throw css::registry::InvalidRegistryException( |
| 516 | reader_.getUrl() + ": expected element attribute \"name\"", |
| 517 | css::uno::Reference< css::uno::XInterface >()); |
| 518 | } |
| 519 | } |
| 520 | if (attrName.isEmpty()) { |
| 521 | throw css::registry::InvalidRegistryException( |
| 522 | reader_.getUrl() + ": element is missing \"name\" attribute", |
| 523 | css::uno::Reference< css::uno::XInterface >()); |
| 524 | } |
| 525 | return attrName; |
| 526 | } |
| 527 | |
| 528 | class ContentEnumeration: |
| 529 | public cppu::WeakImplHelper1< css::container::XEnumeration >, |
| 530 | private boost::noncopyable |
| 531 | { |
| 532 | public: |
| 533 | explicit ContentEnumeration(std::vector< css::uno::Any > const & factories): |
| 534 | factories_(factories), iterator_(factories_.begin()) {} |
| 535 | |
| 536 | private: |
| 537 | virtual ~ContentEnumeration() {} |
| 538 | |
| 539 | virtual sal_Bool SAL_CALL hasMoreElements() |
| 540 | throw (css::uno::RuntimeException); |
| 541 | |
| 542 | virtual css::uno::Any SAL_CALL nextElement() |
| 543 | throw ( |
| 544 | css::container::NoSuchElementException, |
| 545 | css::lang::WrappedTargetException, css::uno::RuntimeException); |
| 546 | |
| 547 | osl::Mutex mutex_; |
| 548 | std::vector< css::uno::Any > factories_; |
| 549 | std::vector< css::uno::Any >::const_iterator iterator_; |
| 550 | }; |
| 551 | |
| 552 | sal_Bool ContentEnumeration::hasMoreElements() |
| 553 | throw (css::uno::RuntimeException) |
| 554 | { |
| 555 | osl::MutexGuard g(mutex_); |
| 556 | return iterator_ != factories_.end(); |
| 557 | } |
| 558 | |
| 559 | css::uno::Any ContentEnumeration::nextElement() |
| 560 | throw ( |
| 561 | css::container::NoSuchElementException, |
| 562 | css::lang::WrappedTargetException, css::uno::RuntimeException) |
| 563 | { |
| 564 | osl::MutexGuard g(mutex_); |
| 565 | if (iterator_ == factories_.end()) { |
| 566 | throw css::container::NoSuchElementException( |
| 567 | "Bootstrap service manager service enumerator has no more elements", |
| 568 | static_cast< cppu::OWeakObject * >(this)); |
| 569 | } |
| 570 | return *iterator_++; |
| 571 | } |
| 572 | |
| 573 | css::beans::Property getDefaultContextProperty() { |
| 574 | return css::beans::Property( |
| 575 | "DefaultContext", -1, |
| 576 | cppu::UnoType< css::uno::XComponentContext >::get(), |
| 577 | css::beans::PropertyAttribute::READONLY); |
| 578 | } |
| 579 | |
| 580 | typedef cppu::WeakComponentImplHelper8< |
| 581 | css::lang::XServiceInfo, css::lang::XMultiServiceFactory, |
| 582 | css::lang::XMultiComponentFactory, css::container::XSet, |
| 583 | css::container::XContentEnumerationAccess, css::beans::XPropertySet, |
| 584 | css::beans::XPropertySetInfo, css::lang::XEventListener > |
| 585 | ServiceManagerBase; |
| 586 | |
| 587 | class ServiceManager: |
| 588 | private osl::Mutex, public ServiceManagerBase, private boost::noncopyable |
| 589 | { |
| 590 | public: |
| 591 | explicit ServiceManager(rtl::OUString const & rdbUris): |
| 592 | ServiceManagerBase(*static_cast< osl::Mutex * >(this)) |
| 593 | { readRdbs(rdbUris); } |
| 594 | |
| 595 | using ServiceManagerBase::acquire; |
| 596 | using ServiceManagerBase::release; |
| 597 | |
| 598 | void setContext( |
| 599 | css::uno::Reference< css::uno::XComponentContext > const & context) |
| 600 | { |
| 601 | assert(context.is())((context.is()) ? static_cast<void> (0) : __assert_fail ("context.is()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 601, __PRETTY_FUNCTION__)); |
| 602 | assert(!context_.is())((!context_.is()) ? static_cast<void> (0) : __assert_fail ("!context_.is()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 602, __PRETTY_FUNCTION__)); |
| 603 | context_ = context; |
| 604 | } |
| 605 | |
| 606 | css::uno::Reference< css::uno::XComponentContext > getContext() const { |
| 607 | assert(context_.is())((context_.is()) ? static_cast<void> (0) : __assert_fail ("context_.is()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 607, __PRETTY_FUNCTION__)); |
| 608 | return context_; |
| 609 | } |
| 610 | |
| 611 | Data const & getData() const { return data_; } |
| 612 | |
| 613 | void loadImplementation( |
| 614 | css::uno::Reference< css::uno::XComponentContext > const & context, |
| 615 | boost::shared_ptr< ImplementationInfo > const & info, |
| 616 | css::uno::Reference< css::lang::XSingleComponentFactory > * factory1, |
| 617 | css::uno::Reference< css::lang::XSingleServiceFactory > * factory2); |
| 618 | |
| 619 | virtual rtl::OUString SAL_CALL getImplementationName() |
| 620 | throw (css::uno::RuntimeException); |
| 621 | |
| 622 | virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) |
| 623 | throw (css::uno::RuntimeException); |
| 624 | |
| 625 | virtual css::uno::Sequence< rtl::OUString > SAL_CALL |
| 626 | getSupportedServiceNames() throw (css::uno::RuntimeException); |
| 627 | |
| 628 | virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( |
| 629 | rtl::OUString const & aServiceSpecifier) |
| 630 | throw (css::uno::Exception, css::uno::RuntimeException); |
| 631 | |
| 632 | virtual css::uno::Reference< css::uno::XInterface > SAL_CALL |
| 633 | createInstanceWithArguments( |
| 634 | rtl::OUString const & ServiceSpecifier, |
| 635 | css::uno::Sequence< css::uno::Any > const & Arguments) |
| 636 | throw (css::uno::Exception, css::uno::RuntimeException); |
| 637 | |
| 638 | virtual css::uno::Sequence< rtl::OUString > SAL_CALL |
| 639 | getAvailableServiceNames() throw (css::uno::RuntimeException); |
| 640 | |
| 641 | virtual css::uno::Reference< css::uno::XInterface > SAL_CALL |
| 642 | createInstanceWithContext( |
| 643 | rtl::OUString const & aServiceSpecifier, |
| 644 | css::uno::Reference< css::uno::XComponentContext > const & Context) |
| 645 | throw (css::uno::Exception, css::uno::RuntimeException); |
| 646 | |
| 647 | virtual css::uno::Reference< css::uno::XInterface > SAL_CALL |
| 648 | createInstanceWithArgumentsAndContext( |
| 649 | rtl::OUString const & ServiceSpecifier, |
| 650 | css::uno::Sequence< css::uno::Any > const & Arguments, |
| 651 | css::uno::Reference< css::uno::XComponentContext > const & Context) |
| 652 | throw (css::uno::Exception, css::uno::RuntimeException); |
| 653 | |
| 654 | virtual css::uno::Type SAL_CALL getElementType() |
| 655 | throw (css::uno::RuntimeException); |
| 656 | |
| 657 | virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException); |
| 658 | |
| 659 | virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL |
| 660 | createEnumeration() throw (css::uno::RuntimeException); |
| 661 | |
| 662 | virtual sal_Bool SAL_CALL has(css::uno::Any const & aElement) |
| 663 | throw (css::uno::RuntimeException); |
| 664 | |
| 665 | virtual void SAL_CALL insert(css::uno::Any const & aElement) |
| 666 | throw ( |
| 667 | css::lang::IllegalArgumentException, |
| 668 | css::container::ElementExistException, css::uno::RuntimeException); |
| 669 | |
| 670 | virtual void SAL_CALL remove(css::uno::Any const & aElement) |
| 671 | throw ( |
| 672 | css::lang::IllegalArgumentException, |
| 673 | css::container::NoSuchElementException, css::uno::RuntimeException); |
| 674 | |
| 675 | virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL |
| 676 | createContentEnumeration(rtl::OUString const & aServiceName) |
| 677 | throw (css::uno::RuntimeException); |
| 678 | |
| 679 | virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL |
| 680 | getPropertySetInfo() throw (css::uno::RuntimeException); |
| 681 | |
| 682 | virtual void SAL_CALL setPropertyValue( |
| 683 | rtl::OUString const & aPropertyName, css::uno::Any const & aValue) |
| 684 | throw ( |
| 685 | css::beans::UnknownPropertyException, |
| 686 | css::beans::PropertyVetoException, |
| 687 | css::lang::IllegalArgumentException, |
| 688 | css::lang::WrappedTargetException, css::uno::RuntimeException); |
| 689 | |
| 690 | virtual css::uno::Any SAL_CALL getPropertyValue( |
| 691 | rtl::OUString const & PropertyName) |
| 692 | throw ( |
| 693 | css::beans::UnknownPropertyException, |
| 694 | css::lang::WrappedTargetException, css::uno::RuntimeException); |
| 695 | |
| 696 | virtual void SAL_CALL addPropertyChangeListener( |
| 697 | rtl::OUString const & aPropertyName, |
| 698 | css::uno::Reference< css::beans::XPropertyChangeListener > const & |
| 699 | xListener) |
| 700 | throw ( |
| 701 | css::beans::UnknownPropertyException, |
| 702 | css::lang::WrappedTargetException, css::uno::RuntimeException); |
| 703 | |
| 704 | virtual void SAL_CALL removePropertyChangeListener( |
| 705 | rtl::OUString const & aPropertyName, |
| 706 | css::uno::Reference< css::beans::XPropertyChangeListener > const & |
| 707 | aListener) |
| 708 | throw ( |
| 709 | css::beans::UnknownPropertyException, |
| 710 | css::lang::WrappedTargetException, css::uno::RuntimeException); |
| 711 | |
| 712 | virtual void SAL_CALL addVetoableChangeListener( |
| 713 | rtl::OUString const & PropertyName, |
| 714 | css::uno::Reference< css::beans::XVetoableChangeListener > const & |
| 715 | aListener) |
| 716 | throw ( |
| 717 | css::beans::UnknownPropertyException, |
| 718 | css::lang::WrappedTargetException, css::uno::RuntimeException); |
| 719 | |
| 720 | virtual void SAL_CALL removeVetoableChangeListener( |
| 721 | rtl::OUString const & PropertyName, |
| 722 | css::uno::Reference< css::beans::XVetoableChangeListener > const & |
| 723 | aListener) |
| 724 | throw ( |
| 725 | css::beans::UnknownPropertyException, |
| 726 | css::lang::WrappedTargetException, css::uno::RuntimeException); |
| 727 | |
| 728 | virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() |
| 729 | throw (css::uno::RuntimeException); |
| 730 | |
| 731 | virtual css::beans::Property SAL_CALL getPropertyByName( |
| 732 | rtl::OUString const & aName) |
| 733 | throw ( |
| 734 | css::beans::UnknownPropertyException, css::uno::RuntimeException); |
| 735 | |
| 736 | virtual sal_Bool SAL_CALL hasPropertyByName(rtl::OUString const & Name) |
| 737 | throw (css::uno::RuntimeException); |
| 738 | |
| 739 | virtual void SAL_CALL disposing(css::lang::EventObject const & Source) |
| 740 | throw (css::uno::RuntimeException); |
| 741 | |
| 742 | private: |
| 743 | virtual ~ServiceManager() {} |
| 744 | |
| 745 | virtual void SAL_CALL disposing(); |
| 746 | |
| 747 | // needs to be called with rBHelper.rMutex locked: |
| 748 | bool isDisposed() { return rBHelper.bDisposed || rBHelper.bInDispose; } |
| 749 | |
| 750 | void removeEventListenerFromComponent( |
| 751 | css::uno::Reference< css::lang::XComponent > const & component); |
| 752 | |
| 753 | void readRdbs(rtl::OUString const & uris); |
| 754 | |
| 755 | void readRdbDirectory(rtl::OUString const & uri, bool optional); |
| 756 | |
| 757 | void readRdbFile(rtl::OUString const & uri, bool optional); |
| 758 | |
| 759 | bool readLegacyRdbFile(rtl::OUString const & uri); |
| 760 | |
| 761 | rtl::OUString readLegacyRdbString( |
| 762 | rtl::OUString const & uri, RegistryKey & key, |
| 763 | rtl::OUString const & path); |
| 764 | |
| 765 | void readLegacyRdbStrings( |
| 766 | rtl::OUString const & uri, RegistryKey & key, |
| 767 | rtl::OUString const & path, std::vector< rtl::OUString > * strings); |
| 768 | |
| 769 | void insertRdbFiles( |
| 770 | std::vector< rtl::OUString > const & uris, |
| 771 | css::uno::Reference< css::uno::XComponentContext > const & |
| 772 | alientContext); |
| 773 | |
| 774 | void insertLegacyFactory( |
| 775 | css::uno::Reference< css::lang::XServiceInfo > const & factoryInfo); |
| 776 | |
| 777 | bool insertExtraData(Data const & extra); |
| 778 | |
| 779 | void removeRdbFiles(std::vector< rtl::OUString > const & uris); |
| 780 | |
| 781 | bool removeLegacyFactory( |
| 782 | css::uno::Reference< css::lang::XServiceInfo > const & factoryInfo, |
| 783 | bool removeListener); |
| 784 | |
| 785 | void removeImplementation(rtl::OUString name); |
| 786 | |
| 787 | boost::shared_ptr< Implementation > findServiceImplementation( |
| 788 | css::uno::Reference< css::uno::XComponentContext > const & context, |
| 789 | rtl::OUString const & specifier); |
| 790 | |
| 791 | css::uno::Reference< css::uno::XComponentContext > context_; |
| 792 | Data data_; |
| 793 | }; |
| 794 | |
| 795 | class FactoryWrapper: |
| 796 | public cppu::WeakImplHelper3< |
| 797 | css::lang::XSingleComponentFactory, css::lang::XSingleServiceFactory, |
| 798 | css::lang::XServiceInfo >, |
| 799 | private boost::noncopyable |
| 800 | { |
| 801 | public: |
| 802 | FactoryWrapper( |
| 803 | rtl::Reference< ServiceManager > const & manager, |
| 804 | boost::shared_ptr< ImplementationInfo > const & info): |
| 805 | manager_(manager), info_(info), loaded_(false) |
| 806 | { assert(manager.is() && info.get() != 0)((manager.is() && info.get() != 0) ? static_cast<void > (0) : __assert_fail ("manager.is() && info.get() != 0" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 806, __PRETTY_FUNCTION__)); } |
| 807 | |
| 808 | private: |
| 809 | virtual ~FactoryWrapper() {} |
| 810 | |
| 811 | virtual css::uno::Reference< css::uno::XInterface > SAL_CALL |
| 812 | createInstanceWithContext( |
| 813 | css::uno::Reference< css::uno::XComponentContext > const & Context) |
| 814 | throw (css::uno::Exception, css::uno::RuntimeException); |
| 815 | |
| 816 | virtual css::uno::Reference< css::uno::XInterface > SAL_CALL |
| 817 | createInstanceWithArgumentsAndContext( |
| 818 | css::uno::Sequence< css::uno::Any > const & Arguments, |
| 819 | css::uno::Reference< css::uno::XComponentContext > const & Context) |
| 820 | throw (css::uno::Exception, css::uno::RuntimeException); |
| 821 | |
| 822 | virtual css::uno::Reference< css::uno::XInterface > SAL_CALL |
| 823 | createInstance() throw (css::uno::Exception, css::uno::RuntimeException); |
| 824 | |
| 825 | virtual css::uno::Reference< css::uno::XInterface > SAL_CALL |
| 826 | createInstanceWithArguments( |
| 827 | css::uno::Sequence< css::uno::Any > const & Arguments) |
| 828 | throw (css::uno::Exception, css::uno::RuntimeException); |
| 829 | |
| 830 | virtual rtl::OUString SAL_CALL getImplementationName() |
| 831 | throw (css::uno::RuntimeException); |
| 832 | |
| 833 | virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) |
| 834 | throw (css::uno::RuntimeException); |
| 835 | |
| 836 | virtual css::uno::Sequence< rtl::OUString > SAL_CALL |
| 837 | getSupportedServiceNames() throw (css::uno::RuntimeException); |
| 838 | |
| 839 | void loadImplementation( |
| 840 | css::uno::Reference< css::uno::XComponentContext > const & context); |
| 841 | |
| 842 | rtl::Reference< ServiceManager > manager_; |
| 843 | boost::shared_ptr< ImplementationInfo > info_; |
| 844 | |
| 845 | osl::Mutex mutex_; |
| 846 | bool loaded_; |
| 847 | css::uno::Reference< css::lang::XSingleComponentFactory > factory1_; |
| 848 | css::uno::Reference< css::lang::XSingleServiceFactory > factory2_; |
| 849 | }; |
| 850 | |
| 851 | void ServiceManager::loadImplementation( |
| 852 | css::uno::Reference< css::uno::XComponentContext > const & context, |
| 853 | boost::shared_ptr< ImplementationInfo > const & info, |
| 854 | css::uno::Reference< css::lang::XSingleComponentFactory > * factory1, |
| 855 | css::uno::Reference< css::lang::XSingleServiceFactory > * factory2) |
| 856 | { |
| 857 | assert(((info.get() != 0 && factory1 != 0 && !factory1 ->is() && factory2 != 0 && !factory2->is ()) ? static_cast<void> (0) : __assert_fail ("info.get() != 0 && factory1 != 0 && !factory1->is() && factory2 != 0 && !factory2->is()" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 859, __PRETTY_FUNCTION__)) |
| 858 | info.get() != 0 && factory1 != 0 && !factory1->is() && factory2 != 0((info.get() != 0 && factory1 != 0 && !factory1 ->is() && factory2 != 0 && !factory2->is ()) ? static_cast<void> (0) : __assert_fail ("info.get() != 0 && factory1 != 0 && !factory1->is() && factory2 != 0 && !factory2->is()" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 859, __PRETTY_FUNCTION__)) |
| 859 | && !factory2->is())((info.get() != 0 && factory1 != 0 && !factory1 ->is() && factory2 != 0 && !factory2->is ()) ? static_cast<void> (0) : __assert_fail ("info.get() != 0 && factory1 != 0 && !factory1->is() && factory2 != 0 && !factory2->is()" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 859, __PRETTY_FUNCTION__)); |
| 860 | rtl::OUString uri; |
| 861 | try { |
| 862 | uri = cppu::bootstrap_expandUri(info->uri); |
| 863 | } catch (css::lang::IllegalArgumentException & e) { |
| 864 | throw css::uno::DeploymentException( |
| 865 | "Cannot expand URI" + info->uri + ": " + e.Message, |
| 866 | static_cast< cppu::OWeakObject * >(this)); |
| 867 | } |
| 868 | css::uno::Reference< css::uno::XInterface > f0; |
| 869 | // Shortcut loading via SharedLibrary loader, to pass in prefix argument |
| 870 | // (which the loader's activate implementation would normally obtain through |
| 871 | // the legacy xKey argument): |
| 872 | if (!info->alienContext.is() |
| 873 | && info->loader == "com.sun.star.loader.SharedLibrary") |
| 874 | { |
| 875 | rtl::OUString prefix(info->prefix); |
| 876 | if (!prefix.isEmpty()) { |
| 877 | prefix += "_"; |
| 878 | } |
| 879 | f0 = cppu::loadSharedLibComponentFactory( |
| 880 | uri, rtl::OUString(), info->name, this, |
| 881 | css::uno::Reference< css::registry::XRegistryKey >(), prefix); |
| 882 | } else { |
| 883 | SAL_INFO_IF(do { if (true && (!info->prefix.isEmpty())) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Loader " << info->loader << " and non-empty prefix " << info->prefix) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "886" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Loader " << info->loader << " and non-empty prefix " << info->prefix)); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Loader " << info->loader << " and non-empty prefix " << info->prefix; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "886" ": "), sal_detail_stream); } } } while (false) |
| 884 | !info->prefix.isEmpty(), "cppuhelper",do { if (true && (!info->prefix.isEmpty())) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Loader " << info->loader << " and non-empty prefix " << info->prefix) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "886" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Loader " << info->loader << " and non-empty prefix " << info->prefix)); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Loader " << info->loader << " and non-empty prefix " << info->prefix; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "886" ": "), sal_detail_stream); } } } while (false) |
| 885 | "Loader " << info->loader << " and non-empty prefix "do { if (true && (!info->prefix.isEmpty())) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Loader " << info->loader << " and non-empty prefix " << info->prefix) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "886" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Loader " << info->loader << " and non-empty prefix " << info->prefix)); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Loader " << info->loader << " and non-empty prefix " << info->prefix; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "886" ": "), sal_detail_stream); } } } while (false) |
| 886 | << info->prefix)do { if (true && (!info->prefix.isEmpty())) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Loader " << info->loader << " and non-empty prefix " << info->prefix) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "886" ": "), ::sal::detail::unwrapStream( ::sal::detail:: StreamStart() << "Loader " << info->loader << " and non-empty prefix " << info->prefix)); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Loader " << info->loader << " and non-empty prefix " << info->prefix; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "886" ": "), sal_detail_stream); } } } while (false); |
| 887 | css::uno::Reference< css::uno::XComponentContext > ctxt; |
| 888 | css::uno::Reference< css::lang::XMultiComponentFactory > smgr; |
| 889 | if (info->alienContext.is()) { |
| 890 | ctxt = info->alienContext; |
| 891 | smgr = css::uno::Reference< css::lang::XMultiComponentFactory >( |
| 892 | ctxt->getServiceManager(), css::uno::UNO_SET_THROW); |
| 893 | } else { |
| 894 | assert(context.is())((context.is()) ? static_cast<void> (0) : __assert_fail ("context.is()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 894, __PRETTY_FUNCTION__)); |
| 895 | ctxt = context; |
| 896 | smgr = this; |
| 897 | } |
| 898 | css::uno::Reference< css::loader::XImplementationLoader > loader( |
| 899 | smgr->createInstanceWithContext(info->loader, ctxt), |
| 900 | css::uno::UNO_QUERY_THROW); |
| 901 | f0 = loader->activate( |
| 902 | info->name, rtl::OUString(), uri, |
| 903 | css::uno::Reference< css::registry::XRegistryKey >()); |
| 904 | } |
| 905 | factory1->set(f0, css::uno::UNO_QUERY); |
| 906 | if (!factory1->is()) { |
| 907 | factory2->set(f0, css::uno::UNO_QUERY); |
| 908 | } |
| 909 | } |
| 910 | |
| 911 | rtl::OUString ServiceManager::getImplementationName() |
| 912 | throw (css::uno::RuntimeException) |
| 913 | { |
| 914 | return rtl::OUString( |
| 915 | "com.sun.star.comp.cppuhelper.bootstrap.ServiceManager"); |
| 916 | } |
| 917 | |
| 918 | sal_Bool ServiceManager::supportsService(rtl::OUString const & ServiceName) |
| 919 | throw (css::uno::RuntimeException) |
| 920 | { |
| 921 | css::uno::Sequence< rtl::OUString > names(getSupportedServiceNames()); |
| 922 | for (sal_Int32 i = 0; i != names.getLength(); ++i) { |
| 923 | if (ServiceName == names[i]) { |
| 924 | return true; |
| 925 | } |
| 926 | } |
| 927 | return false; |
| 928 | } |
| 929 | |
| 930 | css::uno::Sequence< rtl::OUString > ServiceManager::getSupportedServiceNames() |
| 931 | throw (css::uno::RuntimeException) |
| 932 | { |
| 933 | css::uno::Sequence< rtl::OUString > names(2); |
| 934 | names[0] = "com.sun.star.lang.MultiServiceFactory"; |
| 935 | names[1] = "com.sun.star.lang.ServiceManager"; |
| 936 | return names; |
| 937 | } |
| 938 | |
| 939 | css::uno::Reference< css::uno::XInterface > ServiceManager::createInstance( |
| 940 | rtl::OUString const & aServiceSpecifier) |
| 941 | throw (css::uno::Exception, css::uno::RuntimeException) |
| 942 | { |
| 943 | assert(context_.is())((context_.is()) ? static_cast<void> (0) : __assert_fail ("context_.is()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 943, __PRETTY_FUNCTION__)); |
| 944 | return createInstanceWithContext(aServiceSpecifier, context_); |
| 945 | } |
| 946 | |
| 947 | css::uno::Reference< css::uno::XInterface > |
| 948 | ServiceManager::createInstanceWithArguments( |
| 949 | rtl::OUString const & ServiceSpecifier, |
| 950 | css::uno::Sequence< css::uno::Any > const & Arguments) |
| 951 | throw (css::uno::Exception, css::uno::RuntimeException) |
| 952 | { |
| 953 | assert(context_.is())((context_.is()) ? static_cast<void> (0) : __assert_fail ("context_.is()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 953, __PRETTY_FUNCTION__)); |
| 954 | return createInstanceWithArgumentsAndContext( |
| 955 | ServiceSpecifier, Arguments, context_); |
| 956 | } |
| 957 | |
| 958 | css::uno::Sequence< rtl::OUString > ServiceManager::getAvailableServiceNames() |
| 959 | throw (css::uno::RuntimeException) |
| 960 | { |
| 961 | osl::MutexGuard g(rBHelper.rMutex); |
| 962 | if (isDisposed()) { |
| 963 | return css::uno::Sequence< rtl::OUString >(); |
| 964 | } |
| 965 | ImplementationMap::size_type n = data_.services.size(); |
| 966 | if (n > static_cast< sal_uInt32 >(SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF))) { |
| 967 | throw css::uno::RuntimeException( |
| 968 | "getAvailableServiceNames: too many services", |
| 969 | static_cast< cppu::OWeakObject * >(this)); |
| 970 | } |
| 971 | css::uno::Sequence< rtl::OUString > names(static_cast< sal_Int32 >(n)); |
| 972 | sal_Int32 i = 0; |
| 973 | for (ImplementationMap::const_iterator j(data_.services.begin()); |
| 974 | j != data_.services.end(); ++j) |
| 975 | { |
| 976 | names[i++] = j->first; |
| 977 | } |
| 978 | assert(i == names.getLength())((i == names.getLength()) ? static_cast<void> (0) : __assert_fail ("i == names.getLength()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 978, __PRETTY_FUNCTION__)); |
| 979 | return names; |
| 980 | } |
| 981 | |
| 982 | css::uno::Reference< css::uno::XInterface > |
| 983 | ServiceManager::createInstanceWithContext( |
| 984 | rtl::OUString const & aServiceSpecifier, |
| 985 | css::uno::Reference< css::uno::XComponentContext > const & Context) |
| 986 | throw (css::uno::Exception, css::uno::RuntimeException) |
| 987 | { |
| 988 | boost::shared_ptr< Implementation > impl( |
| 989 | findServiceImplementation(Context, aServiceSpecifier)); |
| 990 | if (impl.get() == 0) { |
| 991 | return css::uno::Reference< css::uno::XInterface >(); |
| 992 | } |
| 993 | if (impl->factory1.is()) { |
| 994 | return impl->factory1->createInstanceWithContext(Context); |
| 995 | } |
| 996 | if (impl->factory2.is()) { |
| 997 | return impl->factory2->createInstance(); |
| 998 | } |
| 999 | throw css::uno::DeploymentException( |
| 1000 | "Implementation " + impl->info->name + " does not provide a factory", |
| 1001 | static_cast< cppu::OWeakObject * >(this)); |
| 1002 | } |
| 1003 | |
| 1004 | css::uno::Reference< css::uno::XInterface > |
| 1005 | ServiceManager::createInstanceWithArgumentsAndContext( |
| 1006 | rtl::OUString const & ServiceSpecifier, |
| 1007 | css::uno::Sequence< css::uno::Any > const & Arguments, |
| 1008 | css::uno::Reference< css::uno::XComponentContext > const & Context) |
| 1009 | throw (css::uno::Exception, css::uno::RuntimeException) |
| 1010 | { |
| 1011 | boost::shared_ptr< Implementation > impl( |
| 1012 | findServiceImplementation(Context, ServiceSpecifier)); |
| 1013 | if (impl.get() == 0) { |
| 1014 | return css::uno::Reference< css::uno::XInterface >(); |
| 1015 | } |
| 1016 | if (impl->factory1.is()) { |
| 1017 | return impl->factory1->createInstanceWithArgumentsAndContext( |
| 1018 | Arguments, Context); |
| 1019 | } |
| 1020 | if (impl->factory2.is()) { |
| 1021 | return impl->factory2->createInstanceWithArguments(Arguments); |
| 1022 | } |
| 1023 | throw css::uno::DeploymentException( |
| 1024 | "Implementation " + impl->info->name + " does not provide a factory", |
| 1025 | static_cast< cppu::OWeakObject * >(this)); |
| 1026 | } |
| 1027 | |
| 1028 | css::uno::Type ServiceManager::getElementType() |
| 1029 | throw (css::uno::RuntimeException) |
| 1030 | { |
| 1031 | return css::uno::Type(); |
| 1032 | } |
| 1033 | |
| 1034 | sal_Bool ServiceManager::hasElements() throw (css::uno::RuntimeException) { |
| 1035 | osl::MutexGuard g(rBHelper.rMutex); |
| 1036 | return |
| 1037 | !(data_.namedImplementations.empty() |
| 1038 | && data_.dynamicImplementations.empty()); |
| 1039 | } |
| 1040 | |
| 1041 | css::uno::Reference< css::container::XEnumeration > |
| 1042 | ServiceManager::createEnumeration() throw (css::uno::RuntimeException) { |
| 1043 | throw css::uno::RuntimeException( |
| 1044 | "ServiceManager createEnumeration: method not supported", |
| 1045 | static_cast< cppu::OWeakObject * >(this)); |
| 1046 | } |
| 1047 | |
| 1048 | sal_Bool ServiceManager::has(css::uno::Any const &) |
| 1049 | throw (css::uno::RuntimeException) |
| 1050 | { |
| 1051 | throw css::uno::RuntimeException( |
| 1052 | "ServiceManager has: method not supported", |
| 1053 | static_cast< cppu::OWeakObject * >(this)); |
| 1054 | } |
| 1055 | |
| 1056 | void ServiceManager::insert(css::uno::Any const & aElement) |
| 1057 | throw ( |
| 1058 | css::lang::IllegalArgumentException, |
| 1059 | css::container::ElementExistException, css::uno::RuntimeException) |
| 1060 | { |
| 1061 | css::uno::Sequence< css::beans::NamedValue > args; |
| 1062 | if (aElement >>= args) { |
| 1063 | std::vector< rtl::OUString > uris; |
| 1064 | css::uno::Reference< css::uno::XComponentContext > alienContext; |
| 1065 | for (sal_Int32 i = 0; i < args.getLength(); ++i) { |
| 1066 | if (args[i].Name == "uri") { |
| 1067 | rtl::OUString uri; |
| 1068 | if (!(args[i].Value >>= uri)) { |
| 1069 | throw css::lang::IllegalArgumentException( |
| 1070 | "Bad uri argument", |
| 1071 | static_cast< cppu::OWeakObject * >(this), 0); |
| 1072 | } |
| 1073 | uris.push_back(uri); |
| 1074 | } else if (args[i].Name == "component-context") { |
| 1075 | if (alienContext.is()) { |
| 1076 | throw css::lang::IllegalArgumentException( |
| 1077 | "Multiple component-context arguments", |
| 1078 | static_cast< cppu::OWeakObject * >(this), 0); |
| 1079 | } |
| 1080 | if (!(args[i].Value >>= alienContext) || !alienContext.is()) { |
| 1081 | throw css::lang::IllegalArgumentException( |
| 1082 | "Bad component-context argument", |
| 1083 | static_cast< cppu::OWeakObject * >(this), 0); |
| 1084 | } |
| 1085 | } else { |
| 1086 | throw css::lang::IllegalArgumentException( |
| 1087 | "Bad argument " + args[i].Name, |
| 1088 | static_cast< cppu::OWeakObject * >(this), 0); |
| 1089 | } |
| 1090 | } |
| 1091 | insertRdbFiles(uris, alienContext); |
| 1092 | return; |
| 1093 | } |
| 1094 | css::uno::Reference< css::lang::XServiceInfo > info; |
| 1095 | if ((aElement >>= info) && info.is()) { |
| 1096 | insertLegacyFactory(info); |
| 1097 | return; |
| 1098 | } |
| 1099 | // At least revisions up to 1.7 of LanguageTool.oxt (incl. the bundled 1.4.0 in |
| 1100 | // module languagetool) contain an (actively registered) factory that does not |
| 1101 | // implement XServiceInfo (see <http://sourceforge.net/tracker/? |
| 1102 | // func=detail&aid=3526635&group_id=110216&atid=655717> "SingletonFactory should |
| 1103 | // implement XServiceInfo"); the old OServiceManager::insert |
| 1104 | // (stoc/source/servicemanager/servicemanager.cxx) silently did not add such |
| 1105 | // broken factories to its m_ImplementationNameMap, so ignore them here for |
| 1106 | // backwards compatibility of live-insertion of extensions, too (can go again |
| 1107 | // for incompatible LO 4): |
| 1108 | #if SUPD370 < 400 |
| 1109 | css::uno::Reference< css::lang::XSingleComponentFactory > legacy; |
| 1110 | if ((aElement >>= legacy) && legacy.is()) { |
| 1111 | SAL_WARN(do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "Ignored XSingleComponentFactory not implementing XServiceInfo" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cppuhelper" ), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1113" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Ignored XSingleComponentFactory not implementing XServiceInfo" )); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Ignored XSingleComponentFactory not implementing XServiceInfo" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cppuhelper" ), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1113" ": "), sal_detail_stream); } } } while (false) |
| 1112 | "cppuhelper",do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "Ignored XSingleComponentFactory not implementing XServiceInfo" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cppuhelper" ), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1113" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Ignored XSingleComponentFactory not implementing XServiceInfo" )); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Ignored XSingleComponentFactory not implementing XServiceInfo" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cppuhelper" ), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1113" ": "), sal_detail_stream); } } } while (false) |
| 1113 | "Ignored XSingleComponentFactory not implementing XServiceInfo")do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "Ignored XSingleComponentFactory not implementing XServiceInfo" ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cppuhelper" ), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1113" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Ignored XSingleComponentFactory not implementing XServiceInfo" )); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Ignored XSingleComponentFactory not implementing XServiceInfo" ; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("cppuhelper" ), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1113" ": "), sal_detail_stream); } } } while (false); |
| 1114 | return; |
| 1115 | } |
| 1116 | #endif |
| 1117 | throw css::lang::IllegalArgumentException( |
| 1118 | "Bad insert element", static_cast< cppu::OWeakObject * >(this), 0); |
| 1119 | } |
| 1120 | |
| 1121 | void ServiceManager::remove(css::uno::Any const & aElement) |
| 1122 | throw ( |
| 1123 | css::lang::IllegalArgumentException, |
| 1124 | css::container::NoSuchElementException, css::uno::RuntimeException) |
| 1125 | { |
| 1126 | css::uno::Sequence< css::beans::NamedValue > args; |
| 1127 | if (aElement >>= args) { |
| 1128 | std::vector< rtl::OUString > uris; |
| 1129 | for (sal_Int32 i = 0; i < args.getLength(); ++i) { |
| 1130 | if (args[i].Name == "uri") { |
| 1131 | rtl::OUString uri; |
| 1132 | if (!(args[i].Value >>= uri)) { |
| 1133 | throw css::lang::IllegalArgumentException( |
| 1134 | "Bad uri argument", |
| 1135 | static_cast< cppu::OWeakObject * >(this), 0); |
| 1136 | } |
| 1137 | uris.push_back(uri); |
| 1138 | } else { |
| 1139 | throw css::lang::IllegalArgumentException( |
| 1140 | "Bad argument " + args[i].Name, |
| 1141 | static_cast< cppu::OWeakObject * >(this), 0); |
| 1142 | } |
| 1143 | } |
| 1144 | removeRdbFiles(uris); |
| 1145 | return; |
| 1146 | } |
| 1147 | css::uno::Reference< css::lang::XServiceInfo > info; |
| 1148 | if ((aElement >>= info) && info.is()) { |
| 1149 | if (!removeLegacyFactory(info, true)) { |
| 1150 | throw css::container::NoSuchElementException( |
| 1151 | "Remove non-inserted factory object", |
| 1152 | static_cast< cppu::OWeakObject * >(this)); |
| 1153 | } |
| 1154 | return; |
| 1155 | } |
| 1156 | rtl::OUString impl; |
| 1157 | if (aElement >>= impl) { |
| 1158 | // For live-removal of extensions: |
| 1159 | removeImplementation(impl); |
| 1160 | return; |
| 1161 | } |
| 1162 | throw css::lang::IllegalArgumentException( |
| 1163 | "Bad remove element", static_cast< cppu::OWeakObject * >(this), 0); |
| 1164 | } |
| 1165 | |
| 1166 | css::uno::Reference< css::container::XEnumeration > |
| 1167 | ServiceManager::createContentEnumeration(rtl::OUString const & aServiceName) |
| 1168 | throw (css::uno::RuntimeException) |
| 1169 | { |
| 1170 | std::vector< boost::shared_ptr< Implementation > > impls; |
| 1171 | { |
| 1172 | osl::MutexGuard g(rBHelper.rMutex); |
| 1173 | ImplementationMap::const_iterator i(data_.services.find(aServiceName)); |
| 1174 | if (i != data_.services.end()) { |
| 1175 | impls = i->second; |
| 1176 | } |
| 1177 | } |
| 1178 | std::vector< css::uno::Any > factories; |
| 1179 | for (std::vector< boost::shared_ptr< Implementation > >::const_iterator i( |
| 1180 | impls.begin()); |
| 1181 | i != impls.end(); ++i) |
| 1182 | { |
| 1183 | Implementation * impl = i->get(); |
| 1184 | assert(impl != 0)((impl != 0) ? static_cast<void> (0) : __assert_fail ("impl != 0" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1184, __PRETTY_FUNCTION__)); |
| 1185 | { |
| 1186 | osl::MutexGuard g(rBHelper.rMutex); |
| 1187 | if (isDisposed()) { |
| 1188 | factories.clear(); |
| 1189 | break; |
| 1190 | } |
| 1191 | if (!impl->loaded) { |
| 1192 | // Postpone actual factory instantiation as long as possible (so |
| 1193 | // that e.g. opening LO's "Tools - Macros" menu does not try to |
| 1194 | // instantiate a JVM, which can lead to a synchronous error |
| 1195 | // dialog when no JVM is specified, and showing the dialog while |
| 1196 | // hovering over a menu can cause trouble): |
| 1197 | impl->factory1 = new FactoryWrapper(this, impl->info); |
| 1198 | impl->loaded = true; |
| 1199 | } |
| 1200 | } |
| 1201 | if (impl->factory1.is()) { |
| 1202 | factories.push_back(css::uno::makeAny(impl->factory1)); |
| 1203 | } else if (impl->factory2.is()) { |
| 1204 | factories.push_back(css::uno::makeAny(impl->factory2)); |
| 1205 | } else { |
| 1206 | throw css::uno::DeploymentException( |
| 1207 | ("Implementation " + impl->info->name |
| 1208 | + " does not provide a factory"), |
| 1209 | static_cast< cppu::OWeakObject * >(this)); |
| 1210 | } |
| 1211 | } |
| 1212 | return new ContentEnumeration(factories); |
| 1213 | } |
| 1214 | |
| 1215 | css::uno::Reference< css::beans::XPropertySetInfo > |
| 1216 | ServiceManager::getPropertySetInfo() throw (css::uno::RuntimeException) { |
| 1217 | return this; |
| 1218 | } |
| 1219 | |
| 1220 | void ServiceManager::setPropertyValue( |
| 1221 | rtl::OUString const & aPropertyName, css::uno::Any const &) |
| 1222 | throw ( |
| 1223 | css::beans::UnknownPropertyException, css::beans::PropertyVetoException, |
| 1224 | css::lang::IllegalArgumentException, css::lang::WrappedTargetException, |
| 1225 | css::uno::RuntimeException) |
| 1226 | { |
| 1227 | if (aPropertyName == "DefaultContext") { |
| 1228 | throw css::beans::PropertyVetoException( |
| 1229 | aPropertyName, static_cast< cppu::OWeakObject * >(this)); |
| 1230 | } else { |
| 1231 | throw css::beans::UnknownPropertyException( |
| 1232 | aPropertyName, static_cast< cppu::OWeakObject * >(this)); |
| 1233 | } |
| 1234 | } |
| 1235 | |
| 1236 | css::uno::Any ServiceManager::getPropertyValue( |
| 1237 | rtl::OUString const & PropertyName) |
| 1238 | throw ( |
| 1239 | css::beans::UnknownPropertyException, css::lang::WrappedTargetException, |
| 1240 | css::uno::RuntimeException) |
| 1241 | { |
| 1242 | if (PropertyName != "DefaultContext") { |
| 1243 | throw css::beans::UnknownPropertyException( |
| 1244 | PropertyName, static_cast< cppu::OWeakObject * >(this)); |
| 1245 | } |
| 1246 | assert(context_.is())((context_.is()) ? static_cast<void> (0) : __assert_fail ("context_.is()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1246, __PRETTY_FUNCTION__)); |
| 1247 | return css::uno::makeAny(context_); |
| 1248 | } |
| 1249 | |
| 1250 | void ServiceManager::addPropertyChangeListener( |
| 1251 | rtl::OUString const & aPropertyName, |
| 1252 | css::uno::Reference< css::beans::XPropertyChangeListener > const & |
| 1253 | xListener) |
| 1254 | throw ( |
| 1255 | css::beans::UnknownPropertyException, css::lang::WrappedTargetException, |
| 1256 | css::uno::RuntimeException) |
| 1257 | { |
| 1258 | if (!aPropertyName.isEmpty() && aPropertyName != "DefaultContext") { |
| 1259 | throw css::beans::UnknownPropertyException( |
| 1260 | aPropertyName, static_cast< cppu::OWeakObject * >(this)); |
| 1261 | } |
| 1262 | // DefaultContext does not change, so just treat it as an event listener: |
| 1263 | return addEventListener(xListener.get()); |
| 1264 | } |
| 1265 | |
| 1266 | void ServiceManager::removePropertyChangeListener( |
| 1267 | rtl::OUString const & aPropertyName, |
| 1268 | css::uno::Reference< css::beans::XPropertyChangeListener > const & |
| 1269 | aListener) |
| 1270 | throw ( |
| 1271 | css::beans::UnknownPropertyException, css::lang::WrappedTargetException, |
| 1272 | css::uno::RuntimeException) |
| 1273 | { |
| 1274 | if (!aPropertyName.isEmpty() && aPropertyName != "DefaultContext") { |
| 1275 | throw css::beans::UnknownPropertyException( |
| 1276 | aPropertyName, static_cast< cppu::OWeakObject * >(this)); |
| 1277 | } |
| 1278 | // DefaultContext does not change, so just treat it as an event listener: |
| 1279 | return removeEventListener(aListener.get()); |
| 1280 | } |
| 1281 | |
| 1282 | void ServiceManager::addVetoableChangeListener( |
| 1283 | rtl::OUString const & PropertyName, |
| 1284 | css::uno::Reference< css::beans::XVetoableChangeListener > const & |
| 1285 | aListener) |
| 1286 | throw ( |
| 1287 | css::beans::UnknownPropertyException, css::lang::WrappedTargetException, |
| 1288 | css::uno::RuntimeException) |
| 1289 | { |
| 1290 | if (!PropertyName.isEmpty() && PropertyName != "DefaultContext") { |
| 1291 | throw css::beans::UnknownPropertyException( |
| 1292 | PropertyName, static_cast< cppu::OWeakObject * >(this)); |
| 1293 | } |
| 1294 | // DefaultContext does not change, so just treat it as an event listener: |
| 1295 | return addEventListener(aListener.get()); |
| 1296 | } |
| 1297 | |
| 1298 | void ServiceManager::removeVetoableChangeListener( |
| 1299 | rtl::OUString const & PropertyName, |
| 1300 | css::uno::Reference< css::beans::XVetoableChangeListener > const & |
| 1301 | aListener) |
| 1302 | throw ( |
| 1303 | css::beans::UnknownPropertyException, css::lang::WrappedTargetException, |
| 1304 | css::uno::RuntimeException) |
| 1305 | { |
| 1306 | if (!PropertyName.isEmpty() && PropertyName != "DefaultContext") { |
| 1307 | throw css::beans::UnknownPropertyException( |
| 1308 | PropertyName, static_cast< cppu::OWeakObject * >(this)); |
| 1309 | } |
| 1310 | // DefaultContext does not change, so just treat it as an event listener: |
| 1311 | return removeEventListener(aListener.get()); |
| 1312 | } |
| 1313 | |
| 1314 | css::uno::Sequence< css::beans::Property > ServiceManager::getProperties() |
| 1315 | throw (css::uno::RuntimeException) |
| 1316 | { |
| 1317 | css::uno::Sequence< css::beans::Property > props(1); |
| 1318 | props[0] = getDefaultContextProperty(); |
| 1319 | return props; |
| 1320 | } |
| 1321 | |
| 1322 | css::beans::Property ServiceManager::getPropertyByName( |
| 1323 | rtl::OUString const & aName) |
| 1324 | throw (css::beans::UnknownPropertyException, css::uno::RuntimeException) |
| 1325 | { |
| 1326 | if (aName != "DefaultContext") { |
| 1327 | throw css::beans::UnknownPropertyException( |
| 1328 | aName, static_cast< cppu::OWeakObject * >(this)); |
| 1329 | } |
| 1330 | return getDefaultContextProperty(); |
| 1331 | } |
| 1332 | |
| 1333 | sal_Bool ServiceManager::hasPropertyByName(rtl::OUString const & Name) |
| 1334 | throw (css::uno::RuntimeException) |
| 1335 | { |
| 1336 | return Name == "DefaultContext"; |
| 1337 | } |
| 1338 | |
| 1339 | void ServiceManager::disposing(css::lang::EventObject const & Source) |
| 1340 | throw (css::uno::RuntimeException) |
| 1341 | { |
| 1342 | removeLegacyFactory( |
| 1343 | css::uno::Reference< css::lang::XServiceInfo >( |
| 1344 | Source.Source, css::uno::UNO_QUERY_THROW), |
| 1345 | false); |
| 1346 | } |
| 1347 | |
| 1348 | void ServiceManager::disposing() { |
| 1349 | std::vector< css::uno::Reference< css::lang::XComponent > > comps; |
| 1350 | Data clear; |
| 1351 | { |
| 1352 | osl::MutexGuard g(rBHelper.rMutex); |
| 1353 | for (DynamicImplementations::const_iterator i( |
| 1354 | data_.dynamicImplementations.begin()); |
| 1355 | i != data_.dynamicImplementations.end(); ++i) |
| 1356 | { |
| 1357 | assert(i->second.get() != 0)((i->second.get() != 0) ? static_cast<void> (0) : __assert_fail ("i->second.get() != 0", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1357, __PRETTY_FUNCTION__)); |
| 1358 | if (i->second->component.is()) { |
| 1359 | comps.push_back(i->second->component); |
| 1360 | } |
| 1361 | } |
| 1362 | data_.namedImplementations.swap(clear.namedImplementations); |
| 1363 | data_.dynamicImplementations.swap(clear.dynamicImplementations); |
| 1364 | data_.services.swap(clear.services); |
| 1365 | data_.singletons.swap(clear.singletons); |
| 1366 | } |
| 1367 | for (std::vector< |
| 1368 | css::uno::Reference< css::lang::XComponent > >::const_iterator i( |
| 1369 | comps.begin()); |
| 1370 | i != comps.end(); ++i) |
| 1371 | { |
| 1372 | removeEventListenerFromComponent(*i); |
| 1373 | } |
| 1374 | } |
| 1375 | |
| 1376 | void ServiceManager::removeEventListenerFromComponent( |
| 1377 | css::uno::Reference< css::lang::XComponent > const & component) |
| 1378 | { |
| 1379 | assert(component.is())((component.is()) ? static_cast<void> (0) : __assert_fail ("component.is()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1379, __PRETTY_FUNCTION__)); |
| 1380 | try { |
| 1381 | component->removeEventListener(this); |
| 1382 | } catch (css::uno::RuntimeException & e) { |
| 1383 | SAL_INFO(do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "Ignored removeEventListener RuntimeException " + e.Message) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1385" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Ignored removeEventListener RuntimeException " + e.Message)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Ignored removeEventListener RuntimeException " + e.Message; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1385" ": "), sal_detail_stream); } } } while (false) |
| 1384 | "cppuhelper",do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "Ignored removeEventListener RuntimeException " + e.Message) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1385" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Ignored removeEventListener RuntimeException " + e.Message)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Ignored removeEventListener RuntimeException " + e.Message; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1385" ": "), sal_detail_stream); } } } while (false) |
| 1385 | "Ignored removeEventListener RuntimeException " + e.Message)do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "Ignored removeEventListener RuntimeException " + e.Message) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1385" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Ignored removeEventListener RuntimeException " + e.Message)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Ignored removeEventListener RuntimeException " + e.Message; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1385" ": "), sal_detail_stream); } } } while (false); |
| 1386 | } |
| 1387 | } |
| 1388 | |
| 1389 | void ServiceManager::readRdbs(rtl::OUString const & uris) { |
| 1390 | for (sal_Int32 i = 0; i != -1;) { |
| 1391 | rtl::OUString uri(uris.getToken(0, ' ', i)); |
| 1392 | if (uri.isEmpty()) { |
| 1393 | continue; |
| 1394 | } |
| 1395 | bool optional; |
| 1396 | bool directory; |
| 1397 | decodeRdbUri(&uri, &optional, &directory); |
| 1398 | if (directory) { |
| 1399 | readRdbDirectory(uri, optional); |
| 1400 | } else { |
| 1401 | readRdbFile(uri, optional); |
| 1402 | } |
| 1403 | } |
| 1404 | } |
| 1405 | |
| 1406 | void ServiceManager::readRdbDirectory(rtl::OUString const & uri, bool optional) |
| 1407 | { |
| 1408 | osl::Directory dir(uri); |
| 1409 | switch (dir.open()) { |
| 1410 | case osl::FileBase::E_None: |
| 1411 | break; |
| 1412 | case osl::FileBase::E_NOENT: |
| 1413 | if (optional) { |
| 1414 | SAL_INFO("cppuhelper", "Ignored optional " << uri)do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "Ignored optional " << uri ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("cppuhelper" ), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1414" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Ignored optional " << uri)); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Ignored optional " << uri; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1414" ": "), sal_detail_stream); } } } while (false); |
| 1415 | return; |
| 1416 | } |
| 1417 | // fall through |
| 1418 | default: |
| 1419 | throw css::uno::DeploymentException( |
| 1420 | "Cannot open directory " + uri, |
| 1421 | static_cast< cppu::OWeakObject * >(this)); |
| 1422 | } |
| 1423 | for (;;) { |
| 1424 | rtl::OUString url; |
| 1425 | if (!nextDirectoryItem(dir, &url)) { |
| 1426 | break; |
| 1427 | } |
| 1428 | readRdbFile(url, false); |
| 1429 | } |
| 1430 | } |
| 1431 | |
| 1432 | void ServiceManager::readRdbFile(rtl::OUString const & uri, bool optional) { |
| 1433 | try { |
| 1434 | Parser( |
| 1435 | uri, css::uno::Reference< css::uno::XComponentContext >(), &data_); |
| 1436 | } catch (css::container::NoSuchElementException &) { |
| 1437 | if (!optional) { |
| 1438 | throw css::uno::DeploymentException( |
| 1439 | uri + ": no such file", |
| 1440 | static_cast< cppu::OWeakObject * >(this)); |
| 1441 | } |
| 1442 | SAL_INFO("cppuhelper", "Ignored optional " << uri)do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "Ignored optional " << uri ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("cppuhelper" ), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1442" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Ignored optional " << uri)); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Ignored optional " << uri; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1442" ": "), sal_detail_stream); } } } while (false); |
| 1443 | } catch (css::registry::InvalidRegistryException & e) { |
| 1444 | if (!readLegacyRdbFile(uri)) { |
| 1445 | throw css::uno::DeploymentException( |
| 1446 | "InvalidRegistryException: " + e.Message, |
| 1447 | static_cast< cppu::OWeakObject * >(this)); |
| 1448 | } |
| 1449 | } catch (css::uno::RuntimeException &) { |
| 1450 | if (!readLegacyRdbFile(uri)) { |
| 1451 | throw; |
| 1452 | } |
| 1453 | } |
| 1454 | } |
| 1455 | |
| 1456 | bool ServiceManager::readLegacyRdbFile(rtl::OUString const & uri) { |
| 1457 | Registry reg; |
| 1458 | switch (reg.open(uri, REG_READONLY0x0001)) { |
| 1459 | case REG_NO_ERROR: |
| 1460 | break; |
| 1461 | case REG_REGISTRY_NOT_EXISTS: |
| 1462 | case REG_INVALID_REGISTRY: |
| 1463 | { |
| 1464 | // Ignore empty rdb files (which are at least seen by subordinate |
| 1465 | // uno processes during extension registration; Registry::open can |
| 1466 | // fail on them if mmap(2) returns EINVAL for a zero length): |
| 1467 | osl::DirectoryItem item; |
| 1468 | if (osl::DirectoryItem::get(uri, item) == osl::FileBase::E_None) { |
| 1469 | osl::FileStatus status(osl_FileStatus_Mask_FileSize0x00000080); |
| 1470 | if (item.getFileStatus(status) == osl::FileBase::E_None |
| 1471 | && status.getFileSize() == 0) |
| 1472 | { |
| 1473 | return true; |
| 1474 | } |
| 1475 | } |
| 1476 | } |
| 1477 | // fall through |
| 1478 | default: |
| 1479 | return false; |
| 1480 | } |
| 1481 | RegistryKey rootKey; |
| 1482 | if (reg.openRootKey(rootKey) != REG_NO_ERROR) { |
| 1483 | throw css::uno::DeploymentException( |
| 1484 | "Failure reading legacy rdb file " + uri, |
| 1485 | static_cast< cppu::OWeakObject * >(this)); |
| 1486 | } |
| 1487 | RegistryKeyArray impls; |
| 1488 | switch (rootKey.openSubKeys("IMPLEMENTATIONS", impls)) { |
| 1489 | case REG_NO_ERROR: |
| 1490 | break; |
| 1491 | case REG_KEY_NOT_EXISTS: |
| 1492 | return true; |
| 1493 | default: |
| 1494 | throw css::uno::DeploymentException( |
| 1495 | "Failure reading legacy rdb file " + uri, |
| 1496 | static_cast< cppu::OWeakObject * >(this)); |
| 1497 | } |
| 1498 | for (sal_uInt32 i = 0; i != impls.getLength(); ++i) { |
| 1499 | RegistryKey implKey(impls.getElement(i)); |
| 1500 | assert(implKey.getName().match("/IMPLEMENTATIONS/"))((implKey.getName().match("/IMPLEMENTATIONS/")) ? static_cast <void> (0) : __assert_fail ("implKey.getName().match(\"/IMPLEMENTATIONS/\")" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1500, __PRETTY_FUNCTION__)); |
| 1501 | rtl::OUString name( |
| 1502 | implKey.getName().copy(RTL_CONSTASCII_LENGTH("/IMPLEMENTATIONS/")((sal_Int32)((sizeof ("/IMPLEMENTATIONS/") / sizeof (("/IMPLEMENTATIONS/" )[0]))-1)))); |
| 1503 | boost::shared_ptr< Implementation > impl( |
| 1504 | new Implementation( |
| 1505 | name, readLegacyRdbString(uri, implKey, "UNO/ACTIVATOR"), |
| 1506 | readLegacyRdbString(uri, implKey, "UNO/LOCATION"))); |
| 1507 | if (!data_.namedImplementations.insert( |
| 1508 | NamedImplementations::value_type(name, impl)). |
| 1509 | second) |
| 1510 | { |
| 1511 | throw css::registry::InvalidRegistryException( |
| 1512 | uri + ": duplicate <implementation name=\"" + name + "\">", |
| 1513 | css::uno::Reference< css::uno::XInterface >()); |
| 1514 | } |
| 1515 | readLegacyRdbStrings( |
| 1516 | uri, implKey, "UNO/SERVICES", &impl->info->services); |
| 1517 | for (std::vector< rtl::OUString >::const_iterator j( |
| 1518 | impl->info->services.begin()); |
| 1519 | j != impl->info->services.end(); ++j) |
| 1520 | { |
| 1521 | data_.services[*j].push_back(impl); |
| 1522 | } |
| 1523 | readLegacyRdbStrings( |
| 1524 | uri, implKey, "UNO/SINGLETONS", &impl->info->singletons); |
| 1525 | for (std::vector< rtl::OUString >::const_iterator j( |
| 1526 | impl->info->singletons.begin()); |
| 1527 | j != impl->info->singletons.end(); ++j) |
| 1528 | { |
| 1529 | data_.singletons[*j].push_back(impl); |
| 1530 | } |
| 1531 | } |
| 1532 | return true; |
| 1533 | } |
| 1534 | |
| 1535 | rtl::OUString ServiceManager::readLegacyRdbString( |
| 1536 | rtl::OUString const & uri, RegistryKey & key, rtl::OUString const & path) |
| 1537 | { |
| 1538 | RegistryKey subkey; |
| 1539 | RegValueType t; |
| 1540 | sal_uInt32 s(0); |
| 1541 | if (key.openKey(path, subkey) != REG_NO_ERROR |
| 1542 | || subkey.getValueInfo(rtl::OUString(), &t, &s) != REG_NO_ERROR |
| 1543 | || t != RG_VALUETYPE_STRING |
| 1544 | || s == 0 || s > static_cast< sal_uInt32 >(SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF))) |
| 1545 | { |
| 1546 | throw css::uno::DeploymentException( |
| 1547 | "Failure reading legacy rdb file " + uri, |
| 1548 | static_cast< cppu::OWeakObject * >(this)); |
| 1549 | } |
| 1550 | rtl::OUString val; |
| 1551 | std::vector< char > v(s); // assuming sal_uInt32 fits into vector::size_type |
| 1552 | if (subkey.getValue(rtl::OUString(), &v[0]) != REG_NO_ERROR |
| 1553 | || v.back() != '\0' |
| 1554 | || !rtl_convertStringToUString( |
| 1555 | &val.pData, &v[0], static_cast< sal_Int32 >(s - 1), |
| 1556 | RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)), |
| 1557 | (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR((sal_uInt32)0x0001) |
| 1558 | | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR((sal_uInt32)0x0010) |
| 1559 | | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR((sal_uInt32)0x0100)))) |
| 1560 | { |
| 1561 | throw css::uno::DeploymentException( |
| 1562 | "Failure reading legacy rdb file " + uri, |
| 1563 | static_cast< cppu::OWeakObject * >(this)); |
| 1564 | } |
| 1565 | return val; |
| 1566 | } |
| 1567 | |
| 1568 | void ServiceManager::readLegacyRdbStrings( |
| 1569 | rtl::OUString const & uri, RegistryKey & key, rtl::OUString const & path, |
| 1570 | std::vector< rtl::OUString > * strings) |
| 1571 | { |
| 1572 | assert(strings != 0)((strings != 0) ? static_cast<void> (0) : __assert_fail ("strings != 0", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1572, __PRETTY_FUNCTION__)); |
| 1573 | RegistryKey subkey; |
| 1574 | switch (key.openKey(path, subkey)) { |
| 1575 | case REG_NO_ERROR: |
| 1576 | break; |
| 1577 | case REG_KEY_NOT_EXISTS: |
| 1578 | return; |
| 1579 | default: |
| 1580 | throw css::uno::DeploymentException( |
| 1581 | "Failure reading legacy rdb file " + uri, |
| 1582 | static_cast< cppu::OWeakObject * >(this)); |
| 1583 | } |
| 1584 | rtl::OUString prefix(subkey.getName() + "/"); |
| 1585 | RegistryKeyNames names; |
| 1586 | if (subkey.getKeyNames(rtl::OUString(), names) != REG_NO_ERROR) { |
| 1587 | throw css::uno::DeploymentException( |
| 1588 | "Failure reading legacy rdb file " + uri, |
| 1589 | static_cast< cppu::OWeakObject * >(this)); |
| 1590 | } |
| 1591 | for (sal_uInt32 i = 0; i != names.getLength(); ++i) { |
| 1592 | assert(names.getElement(i).match(prefix))((names.getElement(i).match(prefix)) ? static_cast<void> (0) : __assert_fail ("names.getElement(i).match(prefix)", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1592, __PRETTY_FUNCTION__)); |
| 1593 | strings->push_back(names.getElement(i).copy(prefix.getLength())); |
| 1594 | } |
| 1595 | } |
| 1596 | |
| 1597 | void ServiceManager::insertRdbFiles( |
| 1598 | std::vector< rtl::OUString > const & uris, |
| 1599 | css::uno::Reference< css::uno::XComponentContext > const & alienContext) |
| 1600 | { |
| 1601 | Data extra; |
| 1602 | for (std::vector< rtl::OUString >::const_iterator i(uris.begin()); |
| 1603 | i != uris.end(); ++i) |
| 1604 | { |
| 1605 | try { |
| 1606 | Parser(*i, alienContext, &extra); |
| 1607 | } catch (css::container::NoSuchElementException &) { |
| 1608 | throw css::lang::IllegalArgumentException( |
| 1609 | *i + ": no such file", static_cast< cppu::OWeakObject * >(this), |
| 1610 | 0); |
| 1611 | } catch (css::registry::InvalidRegistryException & e) { |
| 1612 | throw css::lang::IllegalArgumentException( |
| 1613 | "InvalidRegistryException: " + e.Message, |
| 1614 | static_cast< cppu::OWeakObject * >(this), 0); |
| 1615 | } |
| 1616 | } |
| 1617 | insertExtraData(extra); |
| 1618 | } |
| 1619 | |
| 1620 | void ServiceManager::insertLegacyFactory( |
| 1621 | css::uno::Reference< css::lang::XServiceInfo > const & factoryInfo) |
| 1622 | { |
| 1623 | assert(factoryInfo.is())((factoryInfo.is()) ? static_cast<void> (0) : __assert_fail ("factoryInfo.is()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1623, __PRETTY_FUNCTION__)); |
| 1624 | rtl::OUString name(factoryInfo->getImplementationName()); |
| 1625 | css::uno::Reference< css::lang::XSingleComponentFactory > f1( |
| 1626 | factoryInfo, css::uno::UNO_QUERY); |
| 1627 | css::uno::Reference< css::lang::XSingleServiceFactory > f2; |
| 1628 | if (!f1.is()) { |
| 1629 | f2 = css::uno::Reference< css::lang::XSingleServiceFactory >( |
| 1630 | factoryInfo, css::uno::UNO_QUERY); |
| 1631 | } |
| 1632 | css::uno::Reference< css::lang::XComponent > comp( |
| 1633 | factoryInfo, css::uno::UNO_QUERY); |
| 1634 | boost::shared_ptr< Implementation > impl( |
| 1635 | new Implementation(name, f1, f2, comp)); |
| 1636 | Data extra; |
| 1637 | if (!name.isEmpty()) { |
| 1638 | extra.namedImplementations.insert( |
| 1639 | NamedImplementations::value_type(name, impl)); |
| 1640 | } |
| 1641 | extra.dynamicImplementations.insert( |
| 1642 | DynamicImplementations::value_type(factoryInfo, impl)); |
| 1643 | css::uno::Sequence< rtl::OUString > services( |
| 1644 | factoryInfo->getSupportedServiceNames()); |
| 1645 | for (sal_Int32 i = 0; i != services.getLength(); ++i) { |
| 1646 | impl->info->services.push_back(services[i]); |
| 1647 | extra.services[services[i]].push_back(impl); |
| 1648 | } |
| 1649 | if (insertExtraData(extra) && comp.is()) { |
| 1650 | comp->addEventListener(this); |
| 1651 | } |
| 1652 | } |
| 1653 | |
| 1654 | bool ServiceManager::insertExtraData(Data const & extra) { |
| 1655 | { |
| 1656 | osl::MutexGuard g(rBHelper.rMutex); |
| 1657 | if (isDisposed()) { |
| 1658 | return false; |
| 1659 | } |
| 1660 | for (NamedImplementations::const_iterator i( |
| 1661 | extra.namedImplementations.begin()); |
| 1662 | i != extra.namedImplementations.end(); ++i) |
| 1663 | { |
| 1664 | if (data_.namedImplementations.find(i->first) |
| 1665 | != data_.namedImplementations.end()) |
| 1666 | { |
| 1667 | throw css::lang::IllegalArgumentException( |
| 1668 | "Insert duplicate implementation name " + i->first, |
| 1669 | static_cast< cppu::OWeakObject * >(this), 0); |
| 1670 | } |
| 1671 | } |
| 1672 | for (DynamicImplementations::const_iterator i( |
| 1673 | extra.dynamicImplementations.begin()); |
| 1674 | i != extra.dynamicImplementations.end(); ++i) |
| 1675 | { |
| 1676 | if (data_.dynamicImplementations.find(i->first) |
| 1677 | != data_.dynamicImplementations.end()) |
| 1678 | { |
| 1679 | throw css::lang::IllegalArgumentException( |
| 1680 | "Insert duplicate factory object", |
| 1681 | static_cast< cppu::OWeakObject * >(this), 0); |
| 1682 | } |
| 1683 | } |
| 1684 | //TODO: The below leaves data_ in an inconsistent state upon exceptions: |
| 1685 | data_.namedImplementations.insert( |
| 1686 | extra.namedImplementations.begin(), |
| 1687 | extra.namedImplementations.end()); |
| 1688 | data_.dynamicImplementations.insert( |
| 1689 | extra.dynamicImplementations.begin(), |
| 1690 | extra.dynamicImplementations.end()); |
| 1691 | insertImplementationMap(&data_.services, extra.services); |
| 1692 | insertImplementationMap(&data_.singletons, extra.singletons); |
| 1693 | } |
| 1694 | //TODO: Updating the component context singleton data should be part of the |
| 1695 | // atomic service manager update: |
| 1696 | if (!extra.singletons.empty()) { |
| 1697 | assert(context_.is())((context_.is()) ? static_cast<void> (0) : __assert_fail ("context_.is()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1697, __PRETTY_FUNCTION__)); |
| 1698 | css::uno::Reference< css::container::XNameContainer > cont( |
| 1699 | context_, css::uno::UNO_QUERY_THROW); |
| 1700 | for (ImplementationMap::const_iterator i(extra.singletons.begin()); |
| 1701 | i != extra.singletons.end(); ++i) |
| 1702 | { |
| 1703 | rtl::OUString name("/singletons/" + i->first); |
| 1704 | //TODO: Update should be atomic: |
| 1705 | try { |
| 1706 | cont->removeByName(name + "/arguments"); |
| 1707 | } catch (const css::container::NoSuchElementException &) {} |
| 1708 | assert(!i->second.empty())((!i->second.empty()) ? static_cast<void> (0) : __assert_fail ("!i->second.empty()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1708, __PRETTY_FUNCTION__)); |
| 1709 | assert(i->second[0].get() != 0)((i->second[0].get() != 0) ? static_cast<void> (0) : __assert_fail ("i->second[0].get() != 0", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1709, __PRETTY_FUNCTION__)); |
| 1710 | SAL_INFO_IF(do { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for singleton " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1714" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for singleton " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for singleton " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1714" ": "), sal_detail_stream); } } } while (false) |
| 1711 | i->second.size() > 1, "cppuhelper",do { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for singleton " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1714" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for singleton " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for singleton " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1714" ": "), sal_detail_stream); } } } while (false) |
| 1712 | "Arbitrarily chosing " << i->second[0]->info->namedo { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for singleton " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1714" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for singleton " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for singleton " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1714" ": "), sal_detail_stream); } } } while (false) |
| 1713 | << " among multiple implementations for singleton "do { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for singleton " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1714" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for singleton " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for singleton " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1714" ": "), sal_detail_stream); } } } while (false) |
| 1714 | << i->first)do { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for singleton " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1714" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for singleton " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for singleton " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1714" ": "), sal_detail_stream); } } } while (false); |
| 1715 | try { |
| 1716 | cont->insertByName( |
| 1717 | name + "/service", css::uno::Any(i->second[0]->info->name)); |
| 1718 | } catch (css::container::ElementExistException &) { |
| 1719 | cont->replaceByName( |
| 1720 | name + "/service", css::uno::Any(i->second[0]->info->name)); |
| 1721 | } |
| 1722 | try { |
| 1723 | cont->insertByName(name, css::uno::Any()); |
| 1724 | } catch (css::container::ElementExistException &) { |
| 1725 | SAL_INFO("cppuhelper", "Overwriting singleton " << i->first)do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "Overwriting singleton " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1725" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Overwriting singleton " << i-> first)); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Overwriting singleton " << i->first; ::sal ::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1725" ": "), sal_detail_stream); } } } while (false); |
| 1726 | cont->replaceByName(name, css::uno::Any()); |
| 1727 | } |
| 1728 | } |
| 1729 | } |
| 1730 | return true; |
| 1731 | } |
| 1732 | |
| 1733 | void ServiceManager::removeRdbFiles(std::vector< rtl::OUString > const & uris) { |
| 1734 | // The underlying data structures make this function somewhat inefficient, |
| 1735 | // but the assumption is that it is rarely called (and that if it is called, |
| 1736 | // it is called with a uris vector of size one): |
| 1737 | std::vector< boost::shared_ptr< Implementation > > clear; |
| 1738 | { |
| 1739 | osl::MutexGuard g(rBHelper.rMutex); |
| 1740 | for (std::vector< rtl::OUString >::const_iterator i(uris.begin()); |
| 1741 | i != uris.end(); ++i) |
| 1742 | { |
| 1743 | for (NamedImplementations::iterator j( |
| 1744 | data_.namedImplementations.begin()); |
| 1745 | j != data_.namedImplementations.end();) |
| 1746 | { |
| 1747 | assert(j->second.get() != 0)((j->second.get() != 0) ? static_cast<void> (0) : __assert_fail ("j->second.get() != 0", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1747, __PRETTY_FUNCTION__)); |
| 1748 | if (j->second->info->uri == *i) { |
| 1749 | clear.push_back(j->second); |
| 1750 | //TODO: The below leaves data_ in an inconsistent state upon |
| 1751 | // exceptions: |
| 1752 | removeFromImplementationMap( |
| 1753 | &data_.services, j->second->info->services, j->second); |
| 1754 | removeFromImplementationMap( |
| 1755 | &data_.singletons, j->second->info->singletons, |
| 1756 | j->second); |
| 1757 | data_.namedImplementations.erase(j++); |
| 1758 | } else { |
| 1759 | ++j; |
| 1760 | } |
| 1761 | } |
| 1762 | } |
| 1763 | } |
| 1764 | //TODO: Update the component context singleton data |
| 1765 | } |
| 1766 | |
| 1767 | bool ServiceManager::removeLegacyFactory( |
| 1768 | css::uno::Reference< css::lang::XServiceInfo > const & factoryInfo, |
| 1769 | bool removeListener) |
| 1770 | { |
| 1771 | assert(factoryInfo.is())((factoryInfo.is()) ? static_cast<void> (0) : __assert_fail ("factoryInfo.is()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1771, __PRETTY_FUNCTION__)); |
| 1772 | boost::shared_ptr< Implementation > clear; |
| 1773 | css::uno::Reference< css::lang::XComponent > comp; |
| 1774 | { |
| 1775 | osl::MutexGuard g(rBHelper.rMutex); |
| 1776 | DynamicImplementations::iterator i( |
| 1777 | data_.dynamicImplementations.find(factoryInfo)); |
| 1778 | if (i == data_.dynamicImplementations.end()) { |
| 1779 | return isDisposed(); |
| 1780 | } |
| 1781 | assert(i->second.get() != 0)((i->second.get() != 0) ? static_cast<void> (0) : __assert_fail ("i->second.get() != 0", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1781, __PRETTY_FUNCTION__)); |
| 1782 | clear = i->second; |
| 1783 | //TODO: The below leaves data_ in an inconsistent state upon exceptions: |
| 1784 | removeFromImplementationMap( |
| 1785 | &data_.services, i->second->info->services, i->second); |
| 1786 | removeFromImplementationMap( |
| 1787 | &data_.singletons, i->second->info->singletons, i->second); |
| 1788 | if (!i->second->info->name.isEmpty()) { |
| 1789 | data_.namedImplementations.erase(i->second->info->name); |
| 1790 | } |
| 1791 | data_.dynamicImplementations.erase(i); |
| 1792 | if (removeListener) { |
| 1793 | comp = i->second->component; |
| 1794 | } |
| 1795 | } |
| 1796 | if (comp.is()) { |
| 1797 | removeEventListenerFromComponent(comp); |
| 1798 | } |
| 1799 | return true; |
| 1800 | } |
| 1801 | |
| 1802 | void ServiceManager::removeImplementation(rtl::OUString name) { |
| 1803 | // The underlying data structures make this function somewhat inefficient, |
| 1804 | // but the assumption is that it is rarely called: |
| 1805 | boost::shared_ptr< Implementation > clear; |
| 1806 | { |
| 1807 | osl::MutexGuard g(rBHelper.rMutex); |
| 1808 | if (isDisposed()) { |
| 1809 | return; |
| 1810 | } |
| 1811 | NamedImplementations::iterator i(data_.namedImplementations.find(name)); |
| 1812 | if (i == data_.namedImplementations.end()) { |
| 1813 | throw css::container::NoSuchElementException( |
| 1814 | "Remove non-inserted implementation " + name, |
| 1815 | static_cast< cppu::OWeakObject * >(this)); |
| 1816 | } |
| 1817 | assert(i->second.get() != 0)((i->second.get() != 0) ? static_cast<void> (0) : __assert_fail ("i->second.get() != 0", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1817, __PRETTY_FUNCTION__)); |
| 1818 | clear = i->second; |
| 1819 | //TODO: The below leaves data_ in an inconsistent state upon exceptions: |
| 1820 | removeFromImplementationMap( |
| 1821 | &data_.services, i->second->info->services, i->second); |
| 1822 | removeFromImplementationMap( |
| 1823 | &data_.singletons, i->second->info->singletons, i->second); |
| 1824 | for (DynamicImplementations::iterator j( |
| 1825 | data_.dynamicImplementations.begin()); |
| 1826 | j != data_.dynamicImplementations.end(); ++j) |
| 1827 | { |
| 1828 | if (j->second == i->second) { |
| 1829 | data_.dynamicImplementations.erase(j); |
| 1830 | break; |
| 1831 | } |
| 1832 | } |
| 1833 | data_.namedImplementations.erase(i); |
| 1834 | } |
| 1835 | } |
| 1836 | |
| 1837 | boost::shared_ptr< Implementation > ServiceManager::findServiceImplementation( |
| 1838 | css::uno::Reference< css::uno::XComponentContext > const & context, |
| 1839 | rtl::OUString const & specifier) |
| 1840 | { |
| 1841 | boost::shared_ptr< Implementation > impl; |
| 1842 | bool loaded; |
| 1843 | { |
| 1844 | osl::MutexGuard g(rBHelper.rMutex); |
| 1845 | ImplementationMap::const_iterator i(data_.services.find(specifier)); |
| 1846 | if (i == data_.services.end()) { |
| 1847 | NamedImplementations::const_iterator j( |
| 1848 | data_.namedImplementations.find(specifier)); |
| 1849 | if (j == data_.namedImplementations.end()) { |
| 1850 | SAL_INFO("cppuhelper", "No implementation for " << specifier)do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "No implementation for " << specifier) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1850" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "No implementation for " << specifier )); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "No implementation for " << specifier; ::sal:: detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("cppuhelper"), ( "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1850" ": "), sal_detail_stream); } } } while (false); |
| 1851 | return boost::shared_ptr< Implementation >(); |
| 1852 | } |
| 1853 | impl = j->second; |
| 1854 | } else { |
| 1855 | assert(!i->second.empty())((!i->second.empty()) ? static_cast<void> (0) : __assert_fail ("!i->second.empty()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1855, __PRETTY_FUNCTION__)); |
| 1856 | SAL_INFO_IF(do { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1859" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1859" ": "), sal_detail_stream); } } } while (false) |
| 1857 | i->second.size() > 1, "cppuhelper",do { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1859" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1859" ": "), sal_detail_stream); } } } while (false) |
| 1858 | "Arbitrarily chosing " << i->second[0]->info->namedo { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1859" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1859" ": "), sal_detail_stream); } } } while (false) |
| 1859 | << " among multiple implementations for " << i->first)do { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1859" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "1859" ": "), sal_detail_stream); } } } while (false); |
| 1860 | impl = i->second[0]; |
| 1861 | } |
| 1862 | assert(impl.get() != 0)((impl.get() != 0) ? static_cast<void> (0) : __assert_fail ("impl.get() != 0", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 1862, __PRETTY_FUNCTION__)); |
| 1863 | loaded = impl->loaded; |
| 1864 | } |
| 1865 | //TODO: There is a race here, as the relevant service factory can be removed |
| 1866 | // while the mutex is unlocked and loading can thus fail, as the entity from |
| 1867 | // which to load can disappear once the service factory is removed. |
| 1868 | if (!loaded) { |
| 1869 | css::uno::Reference< css::lang::XSingleComponentFactory > f1; |
| 1870 | css::uno::Reference< css::lang::XSingleServiceFactory > f2; |
| 1871 | loadImplementation(context, impl->info, &f1, &f2); |
| 1872 | osl::MutexGuard g(rBHelper.rMutex); |
| 1873 | if (!(isDisposed() || impl->loaded)) { |
| 1874 | impl->loaded = true; |
| 1875 | impl->factory1 = f1; |
| 1876 | impl->factory2 = f2; |
| 1877 | } |
| 1878 | } |
| 1879 | return impl; |
| 1880 | } |
| 1881 | |
| 1882 | css::uno::Reference< css::uno::XInterface > |
| 1883 | FactoryWrapper::createInstanceWithContext( |
| 1884 | css::uno::Reference< css::uno::XComponentContext > const & Context) |
| 1885 | throw (css::uno::Exception, css::uno::RuntimeException) |
| 1886 | { |
| 1887 | loadImplementation(Context); |
| 1888 | return factory1_.is() |
| 1889 | ? factory1_->createInstanceWithContext(Context) |
| 1890 | : factory2_->createInstance(); |
| 1891 | } |
| 1892 | |
| 1893 | css::uno::Reference< css::uno::XInterface > |
| 1894 | FactoryWrapper::createInstanceWithArgumentsAndContext( |
| 1895 | css::uno::Sequence< css::uno::Any > const & Arguments, |
| 1896 | css::uno::Reference< css::uno::XComponentContext > const & Context) |
| 1897 | throw (css::uno::Exception, css::uno::RuntimeException) |
| 1898 | { |
| 1899 | loadImplementation(Context); |
| 1900 | return factory1_.is() |
| 1901 | ? factory1_->createInstanceWithArgumentsAndContext(Arguments, Context) |
| 1902 | : factory2_->createInstanceWithArguments(Arguments); |
| 1903 | } |
| 1904 | |
| 1905 | css::uno::Reference< css::uno::XInterface > FactoryWrapper::createInstance() |
| 1906 | throw (css::uno::Exception, css::uno::RuntimeException) |
| 1907 | { |
| 1908 | loadImplementation(manager_->getContext()); |
| 1909 | return factory1_.is() |
| 1910 | ? factory1_->createInstanceWithContext(manager_->getContext()) |
| 1911 | : factory2_->createInstance(); |
| 1912 | } |
| 1913 | |
| 1914 | css::uno::Reference< css::uno::XInterface > |
| 1915 | FactoryWrapper::createInstanceWithArguments( |
| 1916 | css::uno::Sequence< css::uno::Any > const & Arguments) |
| 1917 | throw (css::uno::Exception, css::uno::RuntimeException) |
| 1918 | { |
| 1919 | loadImplementation(manager_->getContext()); |
Called C++ object pointer is null | |
| 1920 | return factory1_.is() |
| 1921 | ? factory1_->createInstanceWithArgumentsAndContext( |
| 1922 | Arguments, manager_->getContext()) |
| 1923 | : factory2_->createInstanceWithArguments(Arguments); |
| 1924 | } |
| 1925 | |
| 1926 | rtl::OUString FactoryWrapper::getImplementationName() |
| 1927 | throw (css::uno::RuntimeException) |
| 1928 | { |
| 1929 | return info_->name; |
| 1930 | } |
| 1931 | |
| 1932 | sal_Bool FactoryWrapper::supportsService(rtl::OUString const & ServiceName) |
| 1933 | throw (css::uno::RuntimeException) |
| 1934 | { |
| 1935 | css::uno::Sequence< rtl::OUString > names(getSupportedServiceNames()); |
| 1936 | for (sal_Int32 i = 0; i != names.getLength(); ++i) { |
| 1937 | if (ServiceName == names[i]) { |
| 1938 | return true; |
| 1939 | } |
| 1940 | } |
| 1941 | return false; |
| 1942 | } |
| 1943 | |
| 1944 | css::uno::Sequence< rtl::OUString > FactoryWrapper::getSupportedServiceNames() |
| 1945 | throw (css::uno::RuntimeException) |
| 1946 | { |
| 1947 | if (info_->services.size() > static_cast< sal_uInt32 >(SAL_MAX_INT32((sal_Int32) 0x7FFFFFFF))) { |
| 1948 | throw css::uno::RuntimeException( |
| 1949 | "Implementation " + info_->name + " supports too many services", |
| 1950 | static_cast< cppu::OWeakObject * >(this)); |
| 1951 | } |
| 1952 | css::uno::Sequence< rtl::OUString > names( |
| 1953 | static_cast< sal_Int32 >(info_->services.size())); |
| 1954 | sal_Int32 i = 0; |
| 1955 | for (std::vector< rtl::OUString >::const_iterator j( |
| 1956 | info_->services.begin()); |
| 1957 | j != info_->services.end(); ++j) |
| 1958 | { |
| 1959 | names[i++] = *j; |
| 1960 | } |
| 1961 | return names; |
| 1962 | } |
| 1963 | |
| 1964 | void FactoryWrapper::loadImplementation( |
| 1965 | css::uno::Reference< css::uno::XComponentContext > const & context) |
| 1966 | { |
| 1967 | { |
| 1968 | osl::MutexGuard g(mutex_); |
| 1969 | if (loaded_) { |
| 1970 | return; |
| 1971 | } |
| 1972 | } |
| 1973 | css::uno::Reference< css::lang::XSingleComponentFactory > f1; |
| 1974 | css::uno::Reference< css::lang::XSingleServiceFactory > f2; |
| 1975 | //TODO: There is a race here, as the relevant service factory can already |
| 1976 | // have been removed and loading can thus fail, as the entity from which to |
| 1977 | // load can disappear once the service factory is removed: |
| 1978 | manager_->loadImplementation(context, info_, &f1, &f2); |
| 1979 | if (!(f1.is() || f2.is())) { |
| 1980 | throw css::uno::DeploymentException( |
| 1981 | "Implementation " + info_->name + " does not provide a factory", |
| 1982 | static_cast< cppu::OWeakObject * >(this)); |
| 1983 | } |
| 1984 | osl::MutexGuard g(mutex_); |
| 1985 | if (!loaded_) { |
| 1986 | loaded_ = true; |
| 1987 | factory1_ = f1; |
| 1988 | factory2_ = f2; |
| 1989 | } |
| 1990 | } |
| 1991 | |
| 1992 | css::uno::Reference< css::uno::XComponentContext > bootstrapComponentContext( |
| 1993 | css::uno::Reference< css::registry::XSimpleRegistry > const & typeRegistry, |
| 1994 | rtl::OUString const & serviceUris, rtl::Bootstrap const & bootstrap) |
| 1995 | { |
| 1996 | rtl::Reference< ServiceManager > smgr(new ServiceManager(serviceUris)); |
| 1997 | cppu::ContextEntry_Init entry; |
| 1998 | std::vector< cppu::ContextEntry_Init > context_values; |
| 1999 | context_values.push_back( |
| 2000 | cppu::ContextEntry_Init( |
| 2001 | "/singletons/com.sun.star.lang.theServiceManager", |
| 2002 | css::uno::makeAny( |
| 2003 | css::uno::Reference< css::uno::XInterface >( |
| 2004 | static_cast< cppu::OWeakObject * >(smgr.get()))), |
| 2005 | false)); |
| 2006 | context_values.push_back( //TODO: from services.rdb? |
| 2007 | cppu::ContextEntry_Init( |
| 2008 | "/singletons/com.sun.star.reflection.theTypeDescriptionManager", |
| 2009 | css::uno::makeAny( |
| 2010 | rtl::OUString("com.sun.star.comp.stoc.TypeDescriptionManager")), |
| 2011 | true /*TODO: false?*/)); |
| 2012 | context_values.push_back( //TODO: from services.rdb? |
| 2013 | cppu::ContextEntry_Init( |
| 2014 | "/singletons/com.sun.star.util.theMacroExpander", |
| 2015 | css::uno::makeAny( |
| 2016 | cppuhelper::detail::create_bootstrap_macro_expander_factory()), |
| 2017 | true)); |
| 2018 | Data const & data = smgr->getData(); |
| 2019 | for (ImplementationMap::const_iterator i(data.singletons.begin()); |
| 2020 | i != data.singletons.end(); ++i) |
| 2021 | { |
| 2022 | assert(!i->second.empty())((!i->second.empty()) ? static_cast<void> (0) : __assert_fail ("!i->second.empty()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 2022, __PRETTY_FUNCTION__)); |
| 2023 | assert(i->second[0].get() != 0)((i->second[0].get() != 0) ? static_cast<void> (0) : __assert_fail ("i->second[0].get() != 0", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 2023, __PRETTY_FUNCTION__)); |
| 2024 | SAL_INFO_IF(do { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2027" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2027" ": "), sal_detail_stream); } } } while (false) |
| 2025 | i->second.size() > 1, "cppuhelper",do { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2027" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2027" ": "), sal_detail_stream); } } } while (false) |
| 2026 | "Arbitrarily chosing " << i->second[0]->info->namedo { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2027" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2027" ": "), sal_detail_stream); } } } while (false) |
| 2027 | << " among multiple implementations for " << i->first)do { if (true && (i->second.size() > 1)) { if ( sizeof ::sal::detail::getResult( ::sal::detail::StreamStart() << "Arbitrarily chosing " << i->second[0]-> info->name << " among multiple implementations for " << i->first) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2027" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Arbitrarily chosing " << i-> second[0]->info->name << " among multiple implementations for " << i->first)); } else { ::std::ostringstream sal_detail_stream ; sal_detail_stream << "Arbitrarily chosing " << i ->second[0]->info->name << " among multiple implementations for " << i->first; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO ), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2027" ": "), sal_detail_stream); } } } while (false); |
| 2028 | context_values.push_back( |
| 2029 | cppu::ContextEntry_Init( |
| 2030 | "/singletons/" + i->first, |
| 2031 | css::uno::makeAny(i->second[0]->info->name), true)); |
| 2032 | } |
| 2033 | cppu::add_access_control_entries(&context_values, bootstrap); |
| 2034 | assert(!context_values.empty())((!context_values.empty()) ? static_cast<void> (0) : __assert_fail ("!context_values.empty()", "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 2034, __PRETTY_FUNCTION__)); |
| 2035 | css::uno::Reference< css::uno::XComponentContext > context( |
| 2036 | createComponentContext( |
| 2037 | &context_values[0], context_values.size(), |
| 2038 | css::uno::Reference< css::uno::XComponentContext >())); |
| 2039 | smgr->setContext(context); |
| 2040 | css::uno::Reference< css::container::XHierarchicalNameAccess > tdmgr( |
| 2041 | context->getValueByName( |
| 2042 | "/singletons/com.sun.star.reflection.theTypeDescriptionManager"), |
| 2043 | css::uno::UNO_QUERY_THROW); |
| 2044 | if (typeRegistry.is()) { |
| 2045 | css::uno::Sequence< css::uno::Any > arg(1); |
| 2046 | arg[0] <<= typeRegistry; |
| 2047 | css::uno::Reference< css::container::XSet >( |
| 2048 | tdmgr, css::uno::UNO_QUERY_THROW)-> |
| 2049 | insert( |
| 2050 | css::uno::makeAny( |
| 2051 | smgr->createInstanceWithArgumentsAndContext( |
| 2052 | ("com.sun.star.comp.stoc" |
| 2053 | ".RegistryTypeDescriptionProvider"), |
| 2054 | arg, context))); |
| 2055 | } |
| 2056 | cppu::installTypeDescriptionManager(tdmgr); |
| 2057 | return context; |
| 2058 | } |
| 2059 | |
| 2060 | rtl::OUString getBootstrapVariable( |
| 2061 | rtl::Bootstrap const & bootstrap, rtl::OUString const & name) |
| 2062 | { |
| 2063 | rtl::OUString v; |
| 2064 | if (!bootstrap.getFrom(name, v)) { |
| 2065 | throw css::uno::DeploymentException( |
| 2066 | "Cannot obtain " + name + " from uno ini", |
| 2067 | css::uno::Reference< css::uno::XInterface >()); |
| 2068 | } |
| 2069 | return v; |
| 2070 | } |
| 2071 | |
| 2072 | css::uno::Reference< css::registry::XSimpleRegistry > readTypeRdbFile( |
| 2073 | rtl::OUString const & uri, bool optional, |
| 2074 | css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry, |
| 2075 | css::uno::Reference< css::lang::XSingleServiceFactory > const & |
| 2076 | simpleRegistryFactory, |
| 2077 | css::uno::Reference< css::lang::XSingleServiceFactory > const & |
| 2078 | nestedRegistryFactory) |
| 2079 | { |
| 2080 | assert(simpleRegistryFactory.is() && nestedRegistryFactory.is())((simpleRegistryFactory.is() && nestedRegistryFactory .is()) ? static_cast<void> (0) : __assert_fail ("simpleRegistryFactory.is() && nestedRegistryFactory.is()" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 2080, __PRETTY_FUNCTION__)); |
| 2081 | try { |
| 2082 | css::uno::Reference< css::registry::XSimpleRegistry > simple( |
| 2083 | simpleRegistryFactory->createInstance(), css::uno::UNO_QUERY_THROW); |
| 2084 | simple->open(uri, true, false); |
| 2085 | if (lastRegistry.is()) { |
| 2086 | css::uno::Reference< css::registry::XSimpleRegistry > nested( |
| 2087 | nestedRegistryFactory->createInstance(), |
| 2088 | css::uno::UNO_QUERY_THROW); |
| 2089 | css::uno::Sequence< css::uno::Any > args(2); |
| 2090 | args[0] <<= lastRegistry; |
| 2091 | args[1] <<= simple; |
| 2092 | css::uno::Reference< css::lang::XInitialization >( |
| 2093 | nested, css::uno::UNO_QUERY_THROW)-> |
| 2094 | initialize(args); |
| 2095 | return nested; |
| 2096 | } else { |
| 2097 | return simple; |
| 2098 | } |
| 2099 | } catch (css::registry::InvalidRegistryException & e) { |
| 2100 | if (!optional) { |
| 2101 | throw css::uno::DeploymentException( |
| 2102 | "Invalid registry " + uri + ":" + e.Message, |
| 2103 | css::uno::Reference< css::uno::XInterface >()); |
| 2104 | } |
| 2105 | SAL_INFO("cppuhelper", "Ignored optional " << uri)do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "Ignored optional " << uri ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("cppuhelper" ), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2105" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Ignored optional " << uri)); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Ignored optional " << uri; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2105" ": "), sal_detail_stream); } } } while (false); |
| 2106 | return lastRegistry; |
| 2107 | } |
| 2108 | } |
| 2109 | |
| 2110 | css::uno::Reference< css::registry::XSimpleRegistry > readTypeRdbDirectory( |
| 2111 | rtl::OUString const & uri, bool optional, |
| 2112 | css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry, |
| 2113 | css::uno::Reference< css::lang::XSingleServiceFactory > const & |
| 2114 | simpleRegistryFactory, |
| 2115 | css::uno::Reference< css::lang::XSingleServiceFactory > const & |
| 2116 | nestedRegistryFactory) |
| 2117 | { |
| 2118 | assert(simpleRegistryFactory.is() && nestedRegistryFactory.is())((simpleRegistryFactory.is() && nestedRegistryFactory .is()) ? static_cast<void> (0) : __assert_fail ("simpleRegistryFactory.is() && nestedRegistryFactory.is()" , "/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" , 2118, __PRETTY_FUNCTION__)); |
| 2119 | osl::Directory dir(uri); |
| 2120 | switch (dir.open()) { |
| 2121 | case osl::FileBase::E_None: |
| 2122 | break; |
| 2123 | case osl::FileBase::E_NOENT: |
| 2124 | if (optional) { |
| 2125 | SAL_INFO("cppuhelper", "Ignored optional " << uri)do { if (true) { if (sizeof ::sal::detail::getResult( ::sal:: detail::StreamStart() << "Ignored optional " << uri ) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_INFO), ("cppuhelper" ), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2125" ": "), ::sal::detail::unwrapStream( ::sal::detail ::StreamStart() << "Ignored optional " << uri)); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream << "Ignored optional " << uri; ::sal::detail::log ( (::SAL_DETAIL_LOG_LEVEL_INFO), ("cppuhelper"), ("/usr/local/src/libreoffice/cppuhelper/source/defaultbootstrap.cxx" ":" "2125" ": "), sal_detail_stream); } } } while (false); |
| 2126 | return lastRegistry; |
| 2127 | } |
| 2128 | // fall through |
| 2129 | default: |
| 2130 | throw css::uno::DeploymentException( |
| 2131 | "Cannot open directory " + uri, |
| 2132 | css::uno::Reference< css::uno::XInterface >()); |
| 2133 | } |
| 2134 | css::uno::Reference< css::registry::XSimpleRegistry > last(lastRegistry); |
| 2135 | for (;;) { |
| 2136 | rtl::OUString fileUri; |
| 2137 | if (!nextDirectoryItem(dir, &fileUri)) { |
| 2138 | break; |
| 2139 | } |
| 2140 | last = readTypeRdbFile( |
| 2141 | fileUri, optional, last, simpleRegistryFactory, |
| 2142 | nestedRegistryFactory); |
| 2143 | } |
| 2144 | return last; |
| 2145 | } |
| 2146 | |
| 2147 | css::uno::Reference< css::registry::XSimpleRegistry > createTypeRegistry( |
| 2148 | rtl::OUString const & uris, rtl::OUString const & libraryDirectoryUri) |
| 2149 | { |
| 2150 | css::uno::Reference< css::lang::XMultiComponentFactory > factory( |
| 2151 | cppu::bootstrapInitialSF(libraryDirectoryUri)); |
| 2152 | css::uno::Reference< css::lang::XSingleServiceFactory > simpleRegs( |
| 2153 | cppu::loadSharedLibComponentFactory( |
| 2154 | "bootstrap.uno" SAL_DLLEXTENSION".so", libraryDirectoryUri, |
| 2155 | "com.sun.star.comp.stoc.SimpleRegistry", |
| 2156 | css::uno::Reference< css::lang::XMultiServiceFactory >( |
| 2157 | factory, css::uno::UNO_QUERY_THROW), |
| 2158 | css::uno::Reference< css::registry::XRegistryKey >()), |
| 2159 | css::uno::UNO_QUERY_THROW); |
| 2160 | css::uno::Reference< css::lang::XSingleServiceFactory > nestedRegs( |
| 2161 | cppu::loadSharedLibComponentFactory( |
| 2162 | "bootstrap.uno" SAL_DLLEXTENSION".so", libraryDirectoryUri, |
| 2163 | "com.sun.star.comp.stoc.NestedRegistry", |
| 2164 | css::uno::Reference< css::lang::XMultiServiceFactory >( |
| 2165 | factory, css::uno::UNO_QUERY_THROW), |
| 2166 | css::uno::Reference< css::registry::XRegistryKey >()), |
| 2167 | css::uno::UNO_QUERY_THROW); |
| 2168 | css::uno::Reference< css::registry::XSimpleRegistry > reg; |
| 2169 | for (sal_Int32 i = 0; i != -1;) { |
| 2170 | rtl::OUString uri(uris.getToken(0, ' ', i)); |
| 2171 | if (uri.isEmpty()) { |
| 2172 | continue; |
| 2173 | } |
| 2174 | bool optional; |
| 2175 | bool directory; |
| 2176 | decodeRdbUri(&uri, &optional, &directory); |
| 2177 | reg = directory |
| 2178 | ? readTypeRdbDirectory(uri, optional, reg, simpleRegs, nestedRegs) |
| 2179 | : readTypeRdbFile(uri, optional, reg, simpleRegs, nestedRegs); |
| 2180 | } |
| 2181 | return reg; |
| 2182 | } |
| 2183 | |
| 2184 | } |
| 2185 | |
| 2186 | css::uno::Reference< css::uno::XComponentContext > |
| 2187 | cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri) |
| 2188 | SAL_THROW((css::uno::Exception)) |
| 2189 | { |
| 2190 | rtl::Bootstrap bs(iniUri); |
| 2191 | if (bs.getHandle() == 0) { |
| 2192 | throw css::uno::DeploymentException( |
| 2193 | "Cannot open uno ini " + iniUri, |
| 2194 | css::uno::Reference< css::uno::XInterface >()); |
| 2195 | } |
| 2196 | return bootstrapComponentContext( |
| 2197 | createTypeRegistry( |
| 2198 | getBootstrapVariable(bs, "UNO_TYPES"), |
| 2199 | getBootstrapVariable(bs, "URE_INTERNAL_LIB_DIR")), |
| 2200 | getBootstrapVariable(bs, "UNO_SERVICES"), bs); |
| 2201 | } |
| 2202 | |
| 2203 | css::uno::Reference< css::uno::XComponentContext > |
| 2204 | cppu::defaultBootstrap_InitialComponentContext() |
| 2205 | SAL_THROW((css::uno::Exception)) |
| 2206 | { |
| 2207 | return defaultBootstrap_InitialComponentContext(getUnoIniUri()); |
| 2208 | } |
| 2209 | |
| 2210 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |