diff options
Diffstat (limited to 'cppuhelper')
-rw-r--r-- | cppuhelper/source/defaultbootstrap.cxx | 3 | ||||
-rw-r--r-- | cppuhelper/source/typedescriptionprovider.cxx | 124 | ||||
-rw-r--r-- | cppuhelper/source/typedescriptionprovider.hxx | 11 |
3 files changed, 66 insertions, 72 deletions
diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx index 9f0cb52d32e9..39d5b22326e7 100644 --- a/cppuhelper/source/defaultbootstrap.cxx +++ b/cppuhelper/source/defaultbootstrap.cxx @@ -35,6 +35,7 @@ #include "com/sun/star/container/XHierarchicalNameAccess.hpp" #include "com/sun/star/container/XSet.hpp" #include "com/sun/star/uno/DeploymentException.hpp" +#include "com/sun/star/uno/Any.hxx" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/XComponentContext.hpp" #include "cppuhelper/bootstrap.hxx" @@ -117,7 +118,7 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri) tdmgr, css::uno::UNO_QUERY_THROW)-> insert( css::uno::makeAny( - cppuhelper::createTypeDescriptionProvider( + cppuhelper::createTypeDescriptionProviders( getBootstrapVariable(bs, "UNO_TYPES"), smgr.get(), context))); cppu::installTypeDescriptionManager(tdmgr); diff --git a/cppuhelper/source/typedescriptionprovider.cxx b/cppuhelper/source/typedescriptionprovider.cxx index d99650b6bb17..17e447f6f80d 100644 --- a/cppuhelper/source/typedescriptionprovider.cxx +++ b/cppuhelper/source/typedescriptionprovider.cxx @@ -10,13 +10,16 @@ #include "sal/config.h" #include <cassert> +#include <vector> +#include "com/sun/star/container/XHierarchicalNameAccess.hpp" #include "com/sun/star/lang/XInitialization.hpp" #include "com/sun/star/lang/XMultiComponentFactory.hpp" #include "com/sun/star/registry/InvalidRegistryException.hpp" #include "com/sun/star/registry/XSimpleRegistry.hpp" #include "com/sun/star/uno/DeploymentException.hpp" #include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/Sequence.hxx" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XInterface.hpp" #include "osl/file.hxx" @@ -27,52 +30,50 @@ namespace { -css::uno::Reference< css::registry::XSimpleRegistry > readTypeRdbFile( +void readTypeRdbFile( rtl::OUString const & uri, bool optional, - css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry, css::uno::Reference< css::lang::XMultiComponentFactory > const & serviceManager, - css::uno::Reference< css::uno::XComponentContext > const & context) + css::uno::Reference< css::uno::XComponentContext > const & context, + std::vector< + css::uno::Reference< css::container::XHierarchicalNameAccess > > * + providers) { assert(serviceManager.is()); + assert(providers != 0); + css::uno::Reference< css::registry::XSimpleRegistry > reg( + serviceManager->createInstanceWithContext( + "com.sun.star.comp.stoc.SimpleRegistry", context), + css::uno::UNO_QUERY_THROW); try { - css::uno::Reference< css::registry::XSimpleRegistry > simple( - serviceManager->createInstanceWithContext( - "com.sun.star.comp.stoc.SimpleRegistry", context), - css::uno::UNO_QUERY_THROW); - simple->open(uri, true, false); - if (lastRegistry.is()) { - css::uno::Reference< css::registry::XSimpleRegistry > nested( - serviceManager->createInstanceWithContext( - "com.sun.star.comp.stoc.NestedRegistry", context), - css::uno::UNO_QUERY_THROW); - css::uno::Sequence< css::uno::Any > args(2); - args[0] <<= lastRegistry; - args[1] <<= simple; - css::uno::Reference< css::lang::XInitialization >( - nested, css::uno::UNO_QUERY_THROW)-> - initialize(args); - return nested; - } else { - return simple; - } + reg->open(uri, true, false); } catch (css::registry::InvalidRegistryException & e) { - if (!optional) { - throw css::uno::DeploymentException( - "Invalid registry " + uri + ":" + e.Message, - css::uno::Reference< css::uno::XInterface >()); + if (optional) { + SAL_INFO("cppuhelper", "Ignored optional " << uri); + return; } - SAL_INFO("cppuhelper", "Ignored optional " << uri); - return lastRegistry; + throw css::uno::DeploymentException( + "Invalid registry " + uri + ":" + e.Message, + css::uno::Reference< css::uno::XInterface >()); } + css::uno::Sequence< css::uno::Any > arg(1); + arg[0] <<= reg; + providers->push_back( + css::uno::Reference< css::container::XHierarchicalNameAccess >( + serviceManager->createInstanceWithArgumentsAndContext( + "com.sun.star.comp.stoc.RegistryTypeDescriptionProvider", arg, + context), + css::uno::UNO_QUERY_THROW)); } -css::uno::Reference< css::registry::XSimpleRegistry > readTypeRdbDirectory( +void readTypeRdbDirectory( rtl::OUString const & uri, bool optional, - css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry, css::uno::Reference< css::lang::XMultiComponentFactory > const & serviceManager, - css::uno::Reference< css::uno::XComponentContext > const & context) + css::uno::Reference< css::uno::XComponentContext > const & context, + std::vector< + css::uno::Reference< css::container::XHierarchicalNameAccess > > * + providers) { osl::Directory dir(uri); switch (dir.open()) { @@ -81,7 +82,7 @@ css::uno::Reference< css::registry::XSimpleRegistry > readTypeRdbDirectory( case osl::FileBase::E_NOENT: if (optional) { SAL_INFO("cppuhelper", "Ignored optional " << uri); - return lastRegistry; + return; } // fall through default: @@ -89,25 +90,27 @@ css::uno::Reference< css::registry::XSimpleRegistry > readTypeRdbDirectory( "Cannot open directory " + uri, css::uno::Reference< css::uno::XInterface >()); } - css::uno::Reference< css::registry::XSimpleRegistry > last(lastRegistry); for (;;) { rtl::OUString fileUri; if (!cppu::nextDirectoryItem(dir, &fileUri)) { break; } - last = readTypeRdbFile( - fileUri, optional, last, serviceManager, context); + readTypeRdbFile(fileUri, optional, serviceManager, context, providers); } - return last; } -css::uno::Reference< css::registry::XSimpleRegistry > createTypeRegistry( +} + +css::uno::Sequence< + css::uno::Reference< css::container::XHierarchicalNameAccess > > +cppuhelper::createTypeDescriptionProviders( rtl::OUString const & uris, css::uno::Reference< css::lang::XMultiComponentFactory > const & serviceManager, css::uno::Reference< css::uno::XComponentContext > const & context) { - css::uno::Reference< css::registry::XSimpleRegistry > reg; + std::vector< + css::uno::Reference< css::container::XHierarchicalNameAccess > > provs; for (sal_Int32 i = 0; i != -1;) { rtl::OUString uri(uris.getToken(0, ' ', i)); if (uri.isEmpty()) { @@ -116,35 +119,24 @@ css::uno::Reference< css::registry::XSimpleRegistry > createTypeRegistry( bool optional; bool directory; cppu::decodeRdbUri(&uri, &optional, &directory); - reg = directory - ? readTypeRdbDirectory(uri, optional, reg, serviceManager, context) - : readTypeRdbFile(uri, optional, reg, serviceManager, context); + if (directory) { + readTypeRdbDirectory( + uri, optional, serviceManager, context, &provs); + } else { + readTypeRdbFile(uri, optional, serviceManager, context, &provs); + } } - return reg; -} - -} - -css::uno::Reference< css::uno::XInterface > -cppuhelper::createTypeDescriptionProvider( - rtl::OUString const & uris, - css::uno::Reference< css::lang::XMultiComponentFactory > const & - serviceManager, - css::uno::Reference< css::uno::XComponentContext > const & context) -{ - assert(serviceManager.is()); - css::uno::Sequence< css::uno::Any > args; - css::uno::Reference< css::registry::XSimpleRegistry > typereg( - createTypeRegistry(uris, serviceManager, context)); - if (typereg.is()) { - args.realloc(1); - args[0] <<= typereg; + css::uno::Sequence< + css::uno::Reference< css::container::XHierarchicalNameAccess > > provs2( + static_cast< sal_Int32 >(provs.size())); //TODO: check overflow + std::vector< + css::uno::Reference< + css::container::XHierarchicalNameAccess > >::iterator i( + provs.begin()); + for (sal_Int32 j = 0; j != provs2.getLength(); ++j) { + provs2[j] = *i++; } - return css::uno::Reference< css::uno::XInterface >( - serviceManager->createInstanceWithArgumentsAndContext( - "com.sun.star.comp.stoc.RegistryTypeDescriptionProvider", - args, context), - css::uno::UNO_SET_THROW); + return provs2; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/typedescriptionprovider.hxx b/cppuhelper/source/typedescriptionprovider.hxx index f3715e621698..93336e8982f6 100644 --- a/cppuhelper/source/typedescriptionprovider.hxx +++ b/cppuhelper/source/typedescriptionprovider.hxx @@ -13,19 +13,20 @@ #include "sal/config.h" #include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/Sequence.hxx" namespace com { namespace sun { namespace star { + namespace container { class XHierarchicalNameAccess; } namespace lang { class XMultiComponentFactory; } - namespace uno { - class XComponentContext; - class XInterface; - } + namespace uno { class XComponentContext; } } } } namespace rtl { class OUString; } namespace cppuhelper { -css::uno::Reference< css::uno::XInterface > createTypeDescriptionProvider( +css::uno::Sequence< + css::uno::Reference< css::container::XHierarchicalNameAccess > > +createTypeDescriptionProviders( rtl::OUString const & uris, css::uno::Reference< css::lang::XMultiComponentFactory > const & serviceManager, |