diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-04-19 16:59:57 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-04-19 20:57:05 +0200 |
commit | c85ed498bd32733cc9e4574635abbdba40f2aa7c (patch) | |
tree | 215cbb041b4b2d9775e16e1585a7428f1f95a807 /i18npool | |
parent | 9da0670b601c8c186b0bfbd28ea055016db376ad (diff) |
Simplify TransliterationImpl::loadBody
its not evident to me why the original code needed to be so complicated.
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/transliteration/transliterationImpl.cxx | 46 |
1 files changed, 6 insertions, 40 deletions
diff --git a/i18npool/source/transliteration/transliterationImpl.cxx b/i18npool/source/transliteration/transliterationImpl.cxx index eae43fdfc225..5e9f621084ea 100644 --- a/i18npool/source/transliteration/transliterationImpl.cxx +++ b/i18npool/source/transliteration/transliterationImpl.cxx @@ -32,10 +32,6 @@ #include <com/sun/star/i18n/TransliterationType.hpp> #include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/container/XContentEnumerationAccess.hpp> -#include <com/sun/star/container/XEnumeration.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <comphelper/processfactory.hxx> #include <rtl/string.h> @@ -50,7 +46,6 @@ using namespace com::sun::star::uno; using namespace com::sun::star::lang; -using namespace com::sun::star::container; using ::rtl::OUString; @@ -595,44 +590,15 @@ TransliterationImpl::clear() void TransliterationImpl::loadBody( OUString &implName, Reference<XExtendedTransliteration>& body ) throw (RuntimeException) { + assert(!implName.isEmpty()); ::osl::MutexGuard guard(lastTransBody.mutex); - - if (implName.equals(lastTransBody.Name)) + if (implName != lastTransBody.Name) { - // Use the cached body instead of going through the expensive looping again. - body = lastTransBody.Body; - return; - } - - Reference< XContentEnumerationAccess > xEnumAccess( xSMgr, UNO_QUERY ); - Reference< XEnumeration > xEnum(xEnumAccess->createContentEnumeration( - OUString(RTL_CONSTASCII_USTRINGPARAM(TRLT_SERVICELNAME_L10N)))); - if (xEnum.is()) { - while (xEnum->hasMoreElements()) { - Any a = xEnum->nextElement(); - Reference< XServiceInfo > xsInfo; - if (a >>= xsInfo) { - if (implName.equals(xsInfo->getImplementationName())) { - Reference< XSingleServiceFactory > xFactory; - if (a >>= xFactory) { - Reference< XInterface > xI = xFactory->createInstance(); - if (xI.is()) { - a = xI->queryInterface(::getCppuType(( - const Reference<XExtendedTransliteration>*)0)); - a >>= body; - lastTransBody.Name = implName; - lastTransBody.Body = body; - return; - } - } - } - } - } + lastTransBody.Body.set( + xSMgr->createInstance(implName), UNO_QUERY_THROW); + lastTransBody.Name = implName; } - throw RuntimeException( - ("cannot find " TRLT_SERVICELNAME_L10N " service implementation named " - + implName), - Reference< XInterface >()); + body = lastTransBody.Body; } sal_Bool SAL_CALL |