diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-04-26 10:37:56 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-04-26 10:42:49 +0200 |
commit | 19d2de7d5561073f81112974569b98b93d6b7334 (patch) | |
tree | 2c7294fbef163af901933e9ff5b41a9c260fa342 /cppuhelper | |
parent | 5a1d77327867ae9b80bc676d67f1f70a5d8a2fd4 (diff) |
Fix TypeManager
* Make use of unoidl::Manager::createCursor in
TypeManager::createTypeDescriptionEnumeration
* ConstantDescription::getName returned unprefixed name
Change-Id: I4b2e1ce6a240d8f6292375ad36f71e0b19699367
Diffstat (limited to 'cppuhelper')
-rw-r--r-- | cppuhelper/source/typemanager.cxx | 47 | ||||
-rw-r--r-- | cppuhelper/source/typemanager.hxx | 1 |
2 files changed, 26 insertions, 22 deletions
diff --git a/cppuhelper/source/typemanager.cxx b/cppuhelper/source/typemanager.cxx index 4185ddc976b6..8044d826fed2 100644 --- a/cppuhelper/source/typemanager.cxx +++ b/cppuhelper/source/typemanager.cxx @@ -64,6 +64,10 @@ using rtl::OUString; namespace { +rtl::OUString makePrefix(rtl::OUString const & name) { + return name.isEmpty() ? name : name + "."; +} + css::uno::Any resolveTypedefs(css::uno::Any const & type) { for (css::uno::Any t(type);;) { css::uno::Reference< css::reflection::XIndirectTypeDescription > ind( @@ -182,7 +186,7 @@ ModuleDescription::getMembers() throw (css::uno::RuntimeException) { css::uno::Sequence< css::uno::Reference< css::reflection::XTypeDescription > > s(n); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = manager_->resolve(name_ + "." + names[i]); + s[i] = manager_->resolve(makePrefix(name_) + names[i]); } return s; } catch (unoidl::FileFormatException & e) { @@ -1008,7 +1012,8 @@ class ConstantDescription: public cppu::WeakImplHelper1< css::reflection::XConstantTypeDescription > { public: - explicit ConstantDescription( + ConstantDescription( + rtl::OUString const & constantGroupName, unoidl::ConstantGroupEntity::Member const & member); private: @@ -1030,8 +1035,9 @@ private: }; ConstantDescription::ConstantDescription( + rtl::OUString const & constantGroupName, unoidl::ConstantGroupEntity::Member const & member): - name_(member.name) + name_(makePrefix(constantGroupName) + member.name) { switch (member.value.type) { case unoidl::ConstantValue::TYPE_BOOLEAN: @@ -1109,7 +1115,7 @@ ConstantGroupDescription::getConstants() throw (css::uno::RuntimeException) { css::uno::Sequence< css::uno::Reference< css::reflection::XConstantTypeDescription > > s(n); for (sal_Int32 i = 0; i != n; ++i) { - s[i] = new ConstantDescription(entity_->getMembers()[i]); + s[i] = new ConstantDescription(name_, entity_->getMembers()[i]); } return s; } @@ -1778,7 +1784,7 @@ void Enumeration::findNextMatch() { if (deep_) { positions_.push( Position( - name + ".", + makePrefix(name), static_cast< unoidl::ModuleEntity * >( ent.get())->createCursor())); } @@ -1804,7 +1810,7 @@ void Enumeration::findNextMatch() { if (deep_ && matches(css::uno::TypeClass_CONSTANT)) { positions_.push( Position( - name + ".", + makePrefix(name), static_cast< unoidl::ConstantGroupEntity * >( ent.get()))); } @@ -1904,7 +1910,8 @@ css::uno::Any cppuhelper::TypeManager::find(rtl::OUString const & name) { } i = name.lastIndexOf('.'); if (i != -1) { - ent = findEntity(name.copy(0, i)); + rtl::OUString parent(name.copy(0, i)); + ent = findEntity(parent); if (ent.is()) { switch (ent->getSort()) { case unoidl::Entity::SORT_ENUM_TYPE: @@ -1913,6 +1920,7 @@ css::uno::Any cppuhelper::TypeManager::find(rtl::OUString const & name) { name.copy(i + 1)); case unoidl::Entity::SORT_CONSTANT_GROUP: return getConstant( + parent, static_cast< unoidl::ConstantGroupEntity * >(ent.get()), name.copy(i + 1)); default: @@ -2054,29 +2062,23 @@ cppuhelper::TypeManager::createTypeDescriptionEnumeration( css::reflection::InvalidTypeNameException, css::uno::RuntimeException) { - //TODO: This fails for modules spread across multiple providers, esp. for - // the empty moduleName - rtl::Reference< unoidl::Entity > ent(findEntity(moduleName)); - if (!ent.is()) { - throw css::reflection::NoSuchTypeNameException( - moduleName, static_cast< cppu::OWeakObject * >(this)); - } - if (ent->getSort() != unoidl::Entity::SORT_MODULE) { - throw css::reflection::InvalidTypeNameException( - moduleName, static_cast< cppu::OWeakObject * >(this)); - } rtl::Reference< unoidl::MapCursor > cursor; try { - cursor = static_cast< unoidl::ModuleEntity * >(ent.get())-> - createCursor(); + cursor = manager_->createCursor(moduleName); } catch (unoidl::FileFormatException & e) { throw css::uno::DeploymentException( ("unoidl::FileFormatException for <" + e.getUri() + ">: " + e.getDetail()), static_cast< cppu::OWeakObject * >(this)); } + if (!cursor.is()) { + //TODO: css::reflection::InvalidTypeNameException if moduleName names a + // non-module + throw css::reflection::NoSuchTypeNameException( + moduleName, static_cast< cppu::OWeakObject * >(this)); + } return new Enumeration( - this, moduleName + ".", cursor, types, + this, makePrefix(moduleName), cursor, types, depth == css::reflection::TypeDescriptionSearchDepth_INFINITE); } @@ -2338,6 +2340,7 @@ css::uno::Any cppuhelper::TypeManager::getEnumMember( } css::uno::Any cppuhelper::TypeManager::getConstant( + rtl::OUString const & constantGroupName, rtl::Reference< unoidl::ConstantGroupEntity > entity, rtl::OUString const & member) { @@ -2348,7 +2351,7 @@ css::uno::Any cppuhelper::TypeManager::getConstant( if (i->name == member) { return css::uno::makeAny< css::uno::Reference< css::reflection::XTypeDescription > >( - new ConstantDescription(*i)); + new ConstantDescription(constantGroupName, *i)); } } return css::uno::Any(); diff --git a/cppuhelper/source/typemanager.hxx b/cppuhelper/source/typemanager.hxx index a84a2319f3a0..5488aea2ed51 100644 --- a/cppuhelper/source/typemanager.hxx +++ b/cppuhelper/source/typemanager.hxx @@ -136,6 +136,7 @@ private: rtl::OUString const & member); css::uno::Any getConstant( + rtl::OUString const & constantGroupName, rtl::Reference< unoidl::ConstantGroupEntity > entity, rtl::OUString const & member); |