Kaydet (Commit) c85ed498 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Simplify TransliterationImpl::loadBody

its not evident to me why the original code needed to be so complicated.
üst 9da0670b
...@@ -32,10 +32,6 @@ ...@@ -32,10 +32,6 @@
#include <com/sun/star/i18n/TransliterationType.hpp> #include <com/sun/star/i18n/TransliterationType.hpp>
#include <com/sun/star/lang/XComponent.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 <comphelper/processfactory.hxx>
#include <rtl/string.h> #include <rtl/string.h>
...@@ -50,7 +46,6 @@ ...@@ -50,7 +46,6 @@
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
using namespace com::sun::star::lang; using namespace com::sun::star::lang;
using namespace com::sun::star::container;
using ::rtl::OUString; using ::rtl::OUString;
...@@ -595,44 +590,15 @@ TransliterationImpl::clear() ...@@ -595,44 +590,15 @@ TransliterationImpl::clear()
void TransliterationImpl::loadBody( OUString &implName, Reference<XExtendedTransliteration>& body ) void TransliterationImpl::loadBody( OUString &implName, Reference<XExtendedTransliteration>& body )
throw (RuntimeException) throw (RuntimeException)
{ {
assert(!implName.isEmpty());
::osl::MutexGuard guard(lastTransBody.mutex); ::osl::MutexGuard guard(lastTransBody.mutex);
if (implName != lastTransBody.Name)
if (implName.equals(lastTransBody.Name))
{ {
// Use the cached body instead of going through the expensive looping again. lastTransBody.Body.set(
body = lastTransBody.Body; xSMgr->createInstance(implName), UNO_QUERY_THROW);
return; lastTransBody.Name = implName;
}
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;
}
}
}
}
}
} }
throw RuntimeException( body = lastTransBody.Body;
("cannot find " TRLT_SERVICELNAME_L10N " service implementation named "
+ implName),
Reference< XInterface >());
} }
sal_Bool SAL_CALL sal_Bool SAL_CALL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment