diff options
author | Noel Grandin <noel@peralex.com> | 2013-05-13 15:13:34 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-05-14 08:08:26 +0200 |
commit | 0fd6fc3776ada4682e7286f9a0aaaf4c07b42643 (patch) | |
tree | e09685e233909aa2220f224664b68acc2443992b /linguistic | |
parent | fdo#46808, Convert ui::ImageManager to new style (diff) | |
download | core-0fd6fc3776ada4682e7286f9a0aaaf4c07b42643.tar.gz core-0fd6fc3776ada4682e7286f9a0aaaf4c07b42643.zip |
fdo#46808, Convert some XMultiServiceFactory to XComponentContext
Change-Id: Ia66283321d4d18d929b2e3406ad420627f73a3fd
Diffstat (limited to 'linguistic')
-rw-r--r-- | linguistic/source/convdic.cxx | 1 | ||||
-rw-r--r-- | linguistic/source/gciterator.cxx | 14 | ||||
-rw-r--r-- | linguistic/source/gciterator.hxx | 5 | ||||
-rw-r--r-- | linguistic/source/hyphdsp.cxx | 192 | ||||
-rw-r--r-- | linguistic/source/lngsvcmgr.cxx | 324 | ||||
-rw-r--r-- | linguistic/source/spelldsp.cxx | 240 | ||||
-rw-r--r-- | linguistic/source/thesdsp.cxx | 65 |
7 files changed, 403 insertions, 438 deletions
diff --git a/linguistic/source/convdic.cxx b/linguistic/source/convdic.cxx index 502a1b630ae3..c21df30b5879 100644 --- a/linguistic/source/convdic.cxx +++ b/linguistic/source/convdic.cxx @@ -237,7 +237,6 @@ void ConvDic::Save() DBG_ASSERT(!INetURLObject( aMainURL ).HasError(), "invalid URL"); uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); - uno::Reference< lang::XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() ); // get XOutputStream stream uno::Reference< io::XStream > xStream; diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 41214d6f2dfa..4c08a9eed79d 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -233,8 +233,7 @@ static lang::Locale lcl_GetPrimaryLanguageOfSentence( } -GrammarCheckingIterator::GrammarCheckingIterator( const uno::Reference< lang::XMultiServiceFactory > & rxMgr ) : - m_xMSF( rxMgr ), +GrammarCheckingIterator::GrammarCheckingIterator() : m_bEnd( sal_False ), m_aCurCheckedDocId(), m_bGCServicesChecked( sal_False ), @@ -459,10 +458,10 @@ uno::Reference< linguistic2::XProofreader > GrammarCheckingIterator::GetGrammarC { try { - uno::Reference< lang::XMultiServiceFactory > xMgr( - comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); + uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); uno::Reference< linguistic2::XProofreader > xGC( - xMgr->createInstance( aSvcImplName ), uno::UNO_QUERY_THROW ); + xContext->getServiceManager()->createInstanceWithContext(aSvcImplName, xContext), + uno::UNO_QUERY_THROW ); uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xGC, uno::UNO_QUERY_THROW ); if (xSuppLoc->hasLocale( rLocale )) @@ -901,7 +900,6 @@ throw (uno::RuntimeException) // releaase all UNO references - m_xMSF.clear(); m_xBreakIterator.clear(); // clear containers with UNO references AND have those references released @@ -1131,10 +1129,10 @@ static uno::Sequence< OUString > GrammarCheckingIterator_getSupportedServiceName static uno::Reference< uno::XInterface > SAL_CALL GrammarCheckingIterator_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & rxSMgr ) + const uno::Reference< lang::XMultiServiceFactory > & /*rxSMgr*/ ) throw(uno::Exception) { - return static_cast< ::cppu::OWeakObject * >(new GrammarCheckingIterator( rxSMgr )); + return static_cast< ::cppu::OWeakObject * >(new GrammarCheckingIterator()); } diff --git a/linguistic/source/gciterator.hxx b/linguistic/source/gciterator.hxx index 59680bbb62fa..cf2f80711b4a 100644 --- a/linguistic/source/gciterator.hxx +++ b/linguistic/source/gciterator.hxx @@ -83,9 +83,6 @@ class GrammarCheckingIterator: >, public LinguDispatcher { - com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMSF; - - //the queue is keeping track of all senteces to be checked //every element of this queue is a FlatParagraphEntry struct-object typedef std::deque< FPEntry > FPQueue_t; @@ -153,7 +150,7 @@ public: void DequeueAndCheck(); - explicit GrammarCheckingIterator( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rxMgr ); + explicit GrammarCheckingIterator(); virtual ~GrammarCheckingIterator(); // XProofreadingIterator diff --git a/linguistic/source/hyphdsp.cxx b/linguistic/source/hyphdsp.cxx index 75cd9456955f..7b5c0a96a714 100644 --- a/linguistic/source/hyphdsp.cxx +++ b/linguistic/source/hyphdsp.cxx @@ -321,44 +321,43 @@ Reference< XHyphenatedWord > SAL_CALL { Reference< XHyphenator > *pRef = pEntry->aSvcRefs.getArray(); - Reference< XMultiServiceFactory > xMgr( - comphelper::getProcessServiceFactory() ); - if (xMgr.is()) - { - // build service initialization argument - Sequence< Any > aArgs(2); - aArgs.getArray()[0] <<= GetPropSet(); + Reference< XComponentContext > xContext( + comphelper::getProcessComponentContext() ); - // create specific service via it's implementation name - try - { - xHyph = Reference< XHyphenator >( - xMgr->createInstanceWithArguments( - pEntry->aSvcImplNames[0], aArgs ), UNO_QUERY ); - } - catch (uno::Exception &) - { - DBG_ASSERT( 0, "createInstanceWithArguments failed" ); - } - pRef [i] = xHyph; + // build service initialization argument + Sequence< Any > aArgs(2); + aArgs.getArray()[0] <<= GetPropSet(); - Reference< XLinguServiceEventBroadcaster > - xBroadcaster( xHyph, UNO_QUERY ); - if (xBroadcaster.is()) - rMgr.AddLngSvcEvtBroadcaster( xBroadcaster ); + // create specific service via it's implementation name + try + { + xHyph = Reference< XHyphenator >( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + pEntry->aSvcImplNames[0], aArgs, xContext ), + UNO_QUERY ); + } + catch (uno::Exception &) + { + DBG_ASSERT( 0, "createInstanceWithArguments failed" ); + } + pRef [i] = xHyph; - if (xHyph.is() && xHyph->hasLocale( rLocale )) - xRes = xHyph->hyphenate( aChkWord, rLocale, nChkMaxLeading, - rProperties ); + Reference< XLinguServiceEventBroadcaster > + xBroadcaster( xHyph, UNO_QUERY ); + if (xBroadcaster.is()) + rMgr.AddLngSvcEvtBroadcaster( xBroadcaster ); + + if (xHyph.is() && xHyph->hasLocale( rLocale )) + xRes = xHyph->hyphenate( aChkWord, rLocale, nChkMaxLeading, + rProperties ); - pEntry->nLastTriedSvcIndex = (sal_Int16) i; - ++i; + pEntry->nLastTriedSvcIndex = (sal_Int16) i; + ++i; - // if language is not supported by the services - // remove it from the list. - if (xHyph.is() && !xHyph->hasLocale( rLocale )) - aSvcMap.erase( nLanguage ); - } + // if language is not supported by the services + // remove it from the list. + if (xHyph.is() && !xHyph->hasLocale( rLocale )) + aSvcMap.erase( nLanguage ); } } // if (xEntry.is()) } @@ -453,44 +452,42 @@ Reference< XHyphenatedWord > SAL_CALL { Reference< XHyphenator > *pRef = pEntry->aSvcRefs.getArray(); - Reference< XMultiServiceFactory > xMgr( - comphelper::getProcessServiceFactory() ); - if (xMgr.is()) - { - // build service initialization argument - Sequence< Any > aArgs(2); - aArgs.getArray()[0] <<= GetPropSet(); + Reference< XComponentContext > xContext( + comphelper::getProcessComponentContext() ); - // create specific service via it's implementation name - try - { - xHyph = Reference< XHyphenator >( - xMgr->createInstanceWithArguments( - pEntry->aSvcImplNames[0], aArgs ), UNO_QUERY ); - } - catch (uno::Exception &) - { - DBG_ASSERT( 0, "createInstanceWithArguments failed" ); - } - pRef [i] = xHyph; + // build service initialization argument + Sequence< Any > aArgs(2); + aArgs.getArray()[0] <<= GetPropSet(); - Reference< XLinguServiceEventBroadcaster > - xBroadcaster( xHyph, UNO_QUERY ); - if (xBroadcaster.is()) - rMgr.AddLngSvcEvtBroadcaster( xBroadcaster ); + // create specific service via it's implementation name + try + { + xHyph = Reference< XHyphenator >( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + pEntry->aSvcImplNames[0], aArgs, xContext ), UNO_QUERY ); + } + catch (uno::Exception &) + { + DBG_ASSERT( 0, "createInstanceWithArguments failed" ); + } + pRef [i] = xHyph; - if (xHyph.is() && xHyph->hasLocale( rLocale )) - xRes = xHyph->queryAlternativeSpelling( aChkWord, rLocale, - nChkIndex, rProperties ); + Reference< XLinguServiceEventBroadcaster > + xBroadcaster( xHyph, UNO_QUERY ); + if (xBroadcaster.is()) + rMgr.AddLngSvcEvtBroadcaster( xBroadcaster ); - pEntry->nLastTriedSvcIndex = (sal_Int16) i; - ++i; + if (xHyph.is() && xHyph->hasLocale( rLocale )) + xRes = xHyph->queryAlternativeSpelling( aChkWord, rLocale, + nChkIndex, rProperties ); - // if language is not supported by the services - // remove it from the list. - if (xHyph.is() && !xHyph->hasLocale( rLocale )) - aSvcMap.erase( nLanguage ); - } + pEntry->nLastTriedSvcIndex = (sal_Int16) i; + ++i; + + // if language is not supported by the services + // remove it from the list. + if (xHyph.is() && !xHyph->hasLocale( rLocale )) + aSvcMap.erase( nLanguage ); } } // if (xEntry.is()) } @@ -578,43 +575,42 @@ Reference< XPossibleHyphens > SAL_CALL { Reference< XHyphenator > *pRef = pEntry->aSvcRefs.getArray(); - Reference< XMultiServiceFactory > xMgr( - comphelper::getProcessServiceFactory() ); - if (xMgr.is()) - { - // build service initialization argument - Sequence< Any > aArgs(2); - aArgs.getArray()[0] <<= GetPropSet(); + Reference< XComponentContext > xContext( + comphelper::getProcessComponentContext() ); - // create specific service via it's implementation name - try - { - xHyph = Reference< XHyphenator >( - xMgr->createInstanceWithArguments( - pEntry->aSvcImplNames[0], aArgs ), UNO_QUERY ); - } - catch (uno::Exception &) - { - DBG_ASSERT( 0, "createWithArguments failed" ); - } - pRef [i] = xHyph; + // build service initialization argument + Sequence< Any > aArgs(2); + aArgs.getArray()[0] <<= GetPropSet(); + + // create specific service via it's implementation name + try + { + xHyph = Reference< XHyphenator >( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + pEntry->aSvcImplNames[0], aArgs, xContext ), + UNO_QUERY ); + } + catch (uno::Exception &) + { + DBG_ASSERT( 0, "createWithArguments failed" ); + } + pRef [i] = xHyph; - Reference< XLinguServiceEventBroadcaster > - xBroadcaster( xHyph, UNO_QUERY ); - if (xBroadcaster.is()) - rMgr.AddLngSvcEvtBroadcaster( xBroadcaster ); + Reference< XLinguServiceEventBroadcaster > + xBroadcaster( xHyph, UNO_QUERY ); + if (xBroadcaster.is()) + rMgr.AddLngSvcEvtBroadcaster( xBroadcaster ); - if (xHyph.is() && xHyph->hasLocale( rLocale )) - xRes = xHyph->createPossibleHyphens( aChkWord, rLocale, rProperties ); + if (xHyph.is() && xHyph->hasLocale( rLocale )) + xRes = xHyph->createPossibleHyphens( aChkWord, rLocale, rProperties ); - pEntry->nLastTriedSvcIndex = (sal_Int16) i; - ++i; + pEntry->nLastTriedSvcIndex = (sal_Int16) i; + ++i; - // if language is not supported by the services - // remove it from the list. - if (xHyph.is() && !xHyph->hasLocale( rLocale )) - aSvcMap.erase( nLanguage ); - } + // if language is not supported by the services + // remove it from the list. + if (xHyph.is() && !xHyph->hasLocale( rLocale )) + aSvcMap.erase( nLanguage ); } } // if (xEntry.is()) } diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx index 04ee168a2841..2f20fc4d1770 100644 --- a/linguistic/source/lngsvcmgr.cxx +++ b/linguistic/source/lngsvcmgr.cxx @@ -79,9 +79,9 @@ static uno::Sequence< lang::Locale > GetAvailLocales( { uno::Sequence< lang::Locale > aRes; - uno::Reference< lang::XMultiServiceFactory > xFac( comphelper::getProcessServiceFactory() ); + uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); sal_Int32 nNames = rSvcImplNames.getLength(); - if (nNames && xFac.is()) + if( nNames ) { std::set< LanguageType > aLanguages; @@ -101,7 +101,9 @@ static uno::Sequence< lang::Locale > GetAvailLocales( try { xSuppLoc = uno::Reference< linguistic2::XSupportedLocales >( - xFac->createInstanceWithArguments( pImplNames[i], aArgs ), uno::UNO_QUERY ); + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + pImplNames[i], aArgs, xContext ), + uno::UNO_QUERY ); } catch (uno::Exception &) { @@ -1059,56 +1061,51 @@ void LngSvcMgr::GetAvailableSpellSvcs_Impl() { pAvailSpellSvcs = new SvcInfoArray; - uno::Reference< lang::XMultiServiceFactory > xFac( comphelper::getProcessServiceFactory() ); - if (xFac.is()) - { - uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xFac, uno::UNO_QUERY ); - uno::Reference< container::XEnumeration > xEnum; - if (xEnumAccess.is()) - xEnum = xEnumAccess->createContentEnumeration( SN_SPELLCHECKER ); + uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); + + uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xContext->getServiceManager(), uno::UNO_QUERY ); + uno::Reference< container::XEnumeration > xEnum; + if (xEnumAccess.is()) + xEnum = xEnumAccess->createContentEnumeration( SN_SPELLCHECKER ); - if (xEnum.is()) + if (xEnum.is()) + { + while (xEnum->hasMoreElements()) { - while (xEnum->hasMoreElements()) - { - uno::Any aCurrent = xEnum->nextElement(); - uno::Reference< lang::XSingleComponentFactory > xCompFactory; - uno::Reference< lang::XSingleServiceFactory > xFactory; + uno::Any aCurrent = xEnum->nextElement(); + uno::Reference< lang::XSingleComponentFactory > xCompFactory; + uno::Reference< lang::XSingleServiceFactory > xFactory; - uno::Reference< linguistic2::XSpellChecker > xSvc; - if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) ) + uno::Reference< linguistic2::XSpellChecker > xSvc; + if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) ) + { + try { - try - { - uno::Reference < uno::XComponentContext > xContext( - comphelper::getComponentContext( xFac ) ); - xSvc = uno::Reference< linguistic2::XSpellChecker >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY ); - } - catch (const uno::Exception &) - { - DBG_ASSERT( 0, "createInstance failed" ); - } + xSvc = uno::Reference< linguistic2::XSpellChecker >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY ); } - - if (xSvc.is()) + catch (const uno::Exception &) { - OUString aImplName; - uno::Sequence< sal_Int16 > aLanguages; - uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY ); - if (xInfo.is()) - aImplName = xInfo->getImplementationName(); - DBG_ASSERT( !aImplName.isEmpty(), - "empty implementation name" ); - uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY ); - DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" ); - if (xSuppLoc.is()) { - uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales()); - aLanguages = LocaleSeqToLangSeq( aLocaleSequence ); - } - - pAvailSpellSvcs->push_back( new SvcInfo( aImplName, aLanguages ) ); + DBG_ASSERT( 0, "createInstance failed" ); } } + + if (xSvc.is()) + { + OUString aImplName; + uno::Sequence< sal_Int16 > aLanguages; + uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY ); + if (xInfo.is()) + aImplName = xInfo->getImplementationName(); + DBG_ASSERT( !aImplName.isEmpty(), "empty implementation name" ); + uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY ); + DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" ); + if (xSuppLoc.is()) { + uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales()); + aLanguages = LocaleSeqToLangSeq( aLocaleSequence ); + } + + pAvailSpellSvcs->push_back( new SvcInfo( aImplName, aLanguages ) ); + } } } } @@ -1121,55 +1118,51 @@ void LngSvcMgr::GetAvailableGrammarSvcs_Impl() { pAvailGrammarSvcs = new SvcInfoArray; - uno::Reference< lang::XMultiServiceFactory > xFac( comphelper::getProcessServiceFactory() ); - if (xFac.is()) - { - uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xFac, uno::UNO_QUERY ); - uno::Reference< container::XEnumeration > xEnum; - if (xEnumAccess.is()) - xEnum = xEnumAccess->createContentEnumeration( SN_GRAMMARCHECKER ); + uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); + + uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xContext->getServiceManager(), uno::UNO_QUERY ); + uno::Reference< container::XEnumeration > xEnum; + if (xEnumAccess.is()) + xEnum = xEnumAccess->createContentEnumeration( SN_GRAMMARCHECKER ); - if (xEnum.is()) + if (xEnum.is()) + { + while (xEnum->hasMoreElements()) { - while (xEnum->hasMoreElements()) - { - uno::Any aCurrent = xEnum->nextElement(); - uno::Reference< lang::XSingleComponentFactory > xCompFactory; - uno::Reference< lang::XSingleServiceFactory > xFactory; + uno::Any aCurrent = xEnum->nextElement(); + uno::Reference< lang::XSingleComponentFactory > xCompFactory; + uno::Reference< lang::XSingleServiceFactory > xFactory; - uno::Reference< linguistic2::XProofreader > xSvc; - if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) ) + uno::Reference< linguistic2::XProofreader > xSvc; + if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) ) + { + try { - try - { - uno::Reference < uno::XComponentContext > xContext( - comphelper::getComponentContext( xFac ) ); - xSvc = uno::Reference< linguistic2::XProofreader >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY ); - } - catch (const uno::Exception &) - { - DBG_ASSERT( 0, "createInstance failed" ); - } + xSvc = uno::Reference< linguistic2::XProofreader >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY ); } + catch (const uno::Exception &) + { + DBG_ASSERT( 0, "createInstance failed" ); + } + } - if (xSvc.is()) + if (xSvc.is()) + { + OUString aImplName; + uno::Sequence< sal_Int16 > aLanguages; + uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY ); + if (xInfo.is()) + aImplName = xInfo->getImplementationName(); + DBG_ASSERT( !aImplName.isEmpty(),"empty implementation name" ); + uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY ); + DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" ); + if (xSuppLoc.is()) { - OUString aImplName; - uno::Sequence< sal_Int16 > aLanguages; - uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY ); - if (xInfo.is()) - aImplName = xInfo->getImplementationName(); - DBG_ASSERT( !aImplName.isEmpty(), - "empty implementation name" ); - uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY ); - DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" ); - if (xSuppLoc.is()) { - uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales()); - aLanguages = LocaleSeqToLangSeq( aLocaleSequence ); - } - - pAvailGrammarSvcs->push_back( new SvcInfo( aImplName, aLanguages ) ); + uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales()); + aLanguages = LocaleSeqToLangSeq( aLocaleSequence ); } + + pAvailGrammarSvcs->push_back( new SvcInfo( aImplName, aLanguages ) ); } } } @@ -1182,57 +1175,50 @@ void LngSvcMgr::GetAvailableHyphSvcs_Impl() if (!pAvailHyphSvcs) { pAvailHyphSvcs = new SvcInfoArray; - uno::Reference< lang::XMultiServiceFactory > xFac( comphelper::getProcessServiceFactory() ); - if (xFac.is()) - { - uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xFac, uno::UNO_QUERY ); - uno::Reference< container::XEnumeration > xEnum; - if (xEnumAccess.is()) - xEnum = xEnumAccess->createContentEnumeration( SN_HYPHENATOR ); + uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); - if (xEnum.is()) + uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xContext->getServiceManager(), uno::UNO_QUERY ); + uno::Reference< container::XEnumeration > xEnum; + if (xEnumAccess.is()) + xEnum = xEnumAccess->createContentEnumeration( SN_HYPHENATOR ); + + if (xEnum.is()) + { + while (xEnum->hasMoreElements()) { - while (xEnum->hasMoreElements()) - { - uno::Any aCurrent = xEnum->nextElement(); - uno::Reference< lang::XSingleComponentFactory > xCompFactory; - uno::Reference< lang::XSingleServiceFactory > xFactory; + uno::Any aCurrent = xEnum->nextElement(); + uno::Reference< lang::XSingleComponentFactory > xCompFactory; + uno::Reference< lang::XSingleServiceFactory > xFactory; - uno::Reference< linguistic2::XHyphenator > xSvc; - if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) ) + uno::Reference< linguistic2::XHyphenator > xSvc; + if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) ) + { + try { - try - { - uno::Reference < uno::XComponentContext > xContext( - comphelper::getComponentContext( xFac ) ); - xSvc = uno::Reference< linguistic2::XHyphenator >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY ); - - } - catch (const uno::Exception &) - { - DBG_ASSERT( 0, "createInstance failed" ); - } + xSvc = uno::Reference< linguistic2::XHyphenator >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY ); } - - if (xSvc.is()) + catch (const uno::Exception &) { - OUString aImplName; - uno::Sequence< sal_Int16 > aLanguages; - uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY ); - if (xInfo.is()) - aImplName = xInfo->getImplementationName(); - DBG_ASSERT( !aImplName.isEmpty(), - "empty implementation name" ); - uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY ); - DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" ); - if (xSuppLoc.is()) { - uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales()); - aLanguages = LocaleSeqToLangSeq( aLocaleSequence ); - } - - pAvailHyphSvcs->push_back( new SvcInfo( aImplName, aLanguages ) ); + DBG_ASSERT( 0, "createInstance failed" ); } } + if (xSvc.is()) + { + OUString aImplName; + uno::Sequence< sal_Int16 > aLanguages; + uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY ); + if (xInfo.is()) + aImplName = xInfo->getImplementationName(); + DBG_ASSERT( !aImplName.isEmpty(), "empty implementation name" ); + uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY ); + DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" ); + if (xSuppLoc.is()) + { + uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales()); + aLanguages = LocaleSeqToLangSeq( aLocaleSequence ); + } + pAvailHyphSvcs->push_back( new SvcInfo( aImplName, aLanguages ) ); + } } } } @@ -1245,57 +1231,51 @@ void LngSvcMgr::GetAvailableThesSvcs_Impl() { pAvailThesSvcs = new SvcInfoArray; - uno::Reference< lang::XMultiServiceFactory > xFac( comphelper::getProcessServiceFactory() ); - if (xFac.is()) - { - uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xFac, uno::UNO_QUERY ); - uno::Reference< container::XEnumeration > xEnum; - if (xEnumAccess.is()) - xEnum = xEnumAccess->createContentEnumeration( SN_THESAURUS ); + uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() ); - if (xEnum.is()) - { - while (xEnum->hasMoreElements()) - { - uno::Any aCurrent = xEnum->nextElement(); + uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xContext->getServiceManager(), uno::UNO_QUERY ); + uno::Reference< container::XEnumeration > xEnum; + if (xEnumAccess.is()) + xEnum = xEnumAccess->createContentEnumeration( SN_THESAURUS ); - uno::Reference< lang::XSingleComponentFactory > xCompFactory; - uno::Reference< lang::XSingleServiceFactory > xFactory; + if (xEnum.is()) + { + while (xEnum->hasMoreElements()) + { + uno::Any aCurrent = xEnum->nextElement(); + uno::Reference< lang::XSingleComponentFactory > xCompFactory; + uno::Reference< lang::XSingleServiceFactory > xFactory; - uno::Reference< linguistic2::XThesaurus > xSvc; - if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) ) + uno::Reference< linguistic2::XThesaurus > xSvc; + if ( cppu::extractInterface( xCompFactory, aCurrent ) || ::cppu::extractInterface( xFactory, aCurrent ) ) + { + try { - try - { - uno::Reference < uno::XComponentContext > xContext( - comphelper::getComponentContext( xFac ) ); - xSvc = uno::Reference< linguistic2::XThesaurus >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY ); - } - catch (const uno::Exception &) - { - DBG_ASSERT( 0, "createInstance failed" ); - } + xSvc = uno::Reference< linguistic2::XThesaurus >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY ); } - - if (xSvc.is()) + catch (const uno::Exception &) { - OUString aImplName; - uno::Sequence< sal_Int16 > aLanguages; - uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY ); - if (xInfo.is()) - aImplName = xInfo->getImplementationName(); - DBG_ASSERT( !aImplName.isEmpty(), - "empty implementation name" ); - uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY ); - DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" ); - if (xSuppLoc.is()) { - uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales()); - aLanguages = LocaleSeqToLangSeq( aLocaleSequence ); - } - - pAvailThesSvcs->push_back( new SvcInfo( aImplName, aLanguages ) ); + DBG_ASSERT( 0, "createInstance failed" ); } } + if (xSvc.is()) + { + OUString aImplName; + uno::Sequence< sal_Int16 > aLanguages; + uno::Reference< XServiceInfo > xInfo( xSvc, uno::UNO_QUERY ); + if (xInfo.is()) + aImplName = xInfo->getImplementationName(); + DBG_ASSERT( !aImplName.isEmpty(), "empty implementation name" ); + uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xSvc, uno::UNO_QUERY ); + DBG_ASSERT( xSuppLoc.is(), "interfaces not supported" ); + if (xSuppLoc.is()) + { + uno::Sequence<lang::Locale> aLocaleSequence(xSuppLoc->getLocales()); + aLanguages = LocaleSeqToLangSeq( aLocaleSequence ); + } + + pAvailThesSvcs->push_back( new SvcInfo( aImplName, aLanguages ) ); + } } } } diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx index eb41f25243d1..a1d697edff43 100644 --- a/linguistic/source/spelldsp.cxx +++ b/linguistic/source/spelldsp.cxx @@ -360,67 +360,64 @@ sal_Bool SpellCheckerDispatcher::isValid_Impl( const OUString *pImplNames = pEntry->aSvcImplNames.getConstArray(); Reference< XSpellChecker > *pRef = pEntry->aSvcRefs .getArray(); - Reference< XMultiServiceFactory > xMgr( - comphelper::getProcessServiceFactory() ); - if (xMgr.is()) - { - // build service initialization argument - Sequence< Any > aArgs(2); - aArgs.getArray()[0] <<= GetPropSet(); + Reference< XComponentContext > xContext( + comphelper::getProcessComponentContext() ); + + // build service initialization argument + Sequence< Any > aArgs(2); + aArgs.getArray()[0] <<= GetPropSet(); - while (i < nLen && (!bTmpResValid || sal_False == bTmpRes)) + while (i < nLen && (!bTmpResValid || sal_False == bTmpRes)) + { + // create specific service via it's implementation name + Reference< XSpellChecker > xSpell; + try { - // create specific service via it's implementation name - Reference< XSpellChecker > xSpell; - try - { - xSpell = Reference< XSpellChecker >( - xMgr->createInstanceWithArguments( - pImplNames[i], aArgs ), UNO_QUERY ); - } - catch (uno::Exception &) - { - DBG_ASSERT( 0, "createInstanceWithArguments failed" ); - } - pRef [i] = xSpell; + xSpell = Reference< XSpellChecker >( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + pImplNames[i], aArgs, xContext ), + UNO_QUERY ); + } + catch (uno::Exception &) + { + DBG_ASSERT( 0, "createInstanceWithArguments failed" ); + } + pRef [i] = xSpell; - Reference< XLinguServiceEventBroadcaster > - xBroadcaster( xSpell, UNO_QUERY ); - if (xBroadcaster.is()) - rMgr.AddLngSvcEvtBroadcaster( xBroadcaster ); + Reference< XLinguServiceEventBroadcaster > + xBroadcaster( xSpell, UNO_QUERY ); + if (xBroadcaster.is()) + rMgr.AddLngSvcEvtBroadcaster( xBroadcaster ); - bTmpResValid = sal_True; - if (xSpell.is() && xSpell->hasLocale( aLocale )) + bTmpResValid = sal_True; + if (xSpell.is() && xSpell->hasLocale( aLocale )) + { + bTmpRes = GetCache().CheckWord( aChkWord, nLanguage ); + if (!bTmpRes) { - bTmpRes = GetCache().CheckWord( aChkWord, nLanguage ); - if (!bTmpRes) - { - bTmpRes = xSpell->isValid( aChkWord, aLocale, rProperties ); - - // Add correct words to the cache. - // But not those that are correct only because of - // the temporary supplied settings. - if (bTmpRes && 0 == rProperties.getLength()) - GetCache().AddWord( aChkWord, nLanguage ); - } + bTmpRes = xSpell->isValid( aChkWord, aLocale, rProperties ); + // Add correct words to the cache. + // But not those that are correct only because of + // the temporary supplied settings. + if (bTmpRes && 0 == rProperties.getLength()) + GetCache().AddWord( aChkWord, nLanguage ); } - else - bTmpResValid = sal_False; - - if (bTmpResValid) - bRes = bTmpRes; - - pEntry->nLastTriedSvcIndex = (sal_Int16) i; - ++i; } + else + bTmpResValid = sal_False; + if (bTmpResValid) + bRes = bTmpRes; - // if language is not supported by any of the services - // remove it from the list. - if (i == nLen) - { - if (!SvcListHasLanguage( *pEntry, nLanguage )) - aSvcMap.erase( nLanguage ); - } + pEntry->nLastTriedSvcIndex = (sal_Int16) i; + ++i; + } + + // if language is not supported by any of the services + // remove it from the list. + if (i == nLen) + { + if (!SvcListHasLanguage( *pEntry, nLanguage )) + aSvcMap.erase( nLanguage ); } } @@ -548,86 +545,85 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl( const OUString *pImplNames = pEntry->aSvcImplNames.getConstArray(); Reference< XSpellChecker > *pRef = pEntry->aSvcRefs .getArray(); - Reference< XMultiServiceFactory > xMgr( - comphelper::getProcessServiceFactory() ); - if (xMgr.is()) - { - // build service initialization argument - Sequence< Any > aArgs(2); - aArgs.getArray()[0] <<= GetPropSet(); + Reference< XComponentContext > xContext( + comphelper::getProcessComponentContext() ); + + // build service initialization argument + Sequence< Any > aArgs(2); + aArgs.getArray()[0] <<= GetPropSet(); - sal_Int32 nNumSugestions = -1; - while (i < nLen && (!bTmpResValid || xTmpRes.is())) + sal_Int32 nNumSugestions = -1; + while (i < nLen && (!bTmpResValid || xTmpRes.is())) + { + // create specific service via it's implementation name + Reference< XSpellChecker > xSpell; + try { - // create specific service via it's implementation name - Reference< XSpellChecker > xSpell; - try - { - xSpell = Reference< XSpellChecker >( - xMgr->createInstanceWithArguments( - pImplNames[i], aArgs ), UNO_QUERY ); - } - catch (uno::Exception &) - { - DBG_ASSERT( 0, "createInstanceWithArguments failed" ); - } - pRef [i] = xSpell; + xSpell = Reference< XSpellChecker >( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + pImplNames[i], aArgs, xContext ), + UNO_QUERY ); + } + catch (uno::Exception &) + { + DBG_ASSERT( 0, "createInstanceWithArguments failed" ); + } + pRef [i] = xSpell; - Reference< XLinguServiceEventBroadcaster > - xBroadcaster( xSpell, UNO_QUERY ); - if (xBroadcaster.is()) - rMgr.AddLngSvcEvtBroadcaster( xBroadcaster ); + Reference< XLinguServiceEventBroadcaster > + xBroadcaster( xSpell, UNO_QUERY ); + if (xBroadcaster.is()) + rMgr.AddLngSvcEvtBroadcaster( xBroadcaster ); - bTmpResValid = sal_True; - if (xSpell.is() && xSpell->hasLocale( aLocale )) - { - sal_Bool bOK = GetCache().CheckWord( aChkWord, nLanguage ); - if (bOK) - xTmpRes = NULL; - else - { - xTmpRes = xSpell->spell( aChkWord, aLocale, rProperties ); - - // Add correct words to the cache. - // But not those that are correct only because of - // the temporary supplied settings. - if (!xTmpRes.is() && 0 == rProperties.getLength()) - GetCache().AddWord( aChkWord, nLanguage ); - } - } + bTmpResValid = sal_True; + if (xSpell.is() && xSpell->hasLocale( aLocale )) + { + sal_Bool bOK = GetCache().CheckWord( aChkWord, nLanguage ); + if (bOK) + xTmpRes = NULL; else - bTmpResValid = sal_False; - - // return first found result if the word is not known by any checker. - // But if that result has no suggestions use the first one that does - // provide suggestions for the misspelled word. - if (!xRes.is() && bTmpResValid) - { - xRes = xTmpRes; - nNumSugestions = 0; - if (xRes.is()) - nNumSugestions = xRes->getAlternatives().getLength(); - } - sal_Int32 nTmpNumSugestions = 0; - if (xTmpRes.is() && bTmpResValid) - nTmpNumSugestions = xTmpRes->getAlternatives().getLength(); - if (xRes.is() && nNumSugestions == 0 && nTmpNumSugestions > 0) { - xRes = xTmpRes; - nNumSugestions = nTmpNumSugestions; - } + xTmpRes = xSpell->spell( aChkWord, aLocale, rProperties ); - pEntry->nLastTriedSvcIndex = (sal_Int16) i; - ++i; + // Add correct words to the cache. + // But not those that are correct only because of + // the temporary supplied settings. + if (!xTmpRes.is() && 0 == rProperties.getLength()) + GetCache().AddWord( aChkWord, nLanguage ); + } } + else + bTmpResValid = sal_False; - // if language is not supported by any of the services - // remove it from the list. - if (i == nLen) + // return first found result if the word is not known by any checker. + // But if that result has no suggestions use the first one that does + // provide suggestions for the misspelled word. + if (!xRes.is() && bTmpResValid) + { + xRes = xTmpRes; + nNumSugestions = 0; + if (xRes.is()) + nNumSugestions = xRes->getAlternatives().getLength(); + } + sal_Int32 nTmpNumSugestions = 0; + if (xTmpRes.is() && bTmpResValid) + nTmpNumSugestions = xTmpRes->getAlternatives().getLength(); + if (xRes.is() && nNumSugestions == 0 && nTmpNumSugestions > 0) { - if (!SvcListHasLanguage( *pEntry, nLanguage )) - aSvcMap.erase( nLanguage ); + xRes = xTmpRes; + nNumSugestions = nTmpNumSugestions; } + + pEntry->nLastTriedSvcIndex = (sal_Int16) i; + ++i; + } + + // if language is not supported by any of the services + // remove it from the list. + if (i == nLen) + { + if (!SvcListHasLanguage( *pEntry, nLanguage )) + aSvcMap.erase( nLanguage ); } } diff --git a/linguistic/source/thesdsp.cxx b/linguistic/source/thesdsp.cxx index a734d89271cd..c8d31cadc5f2 100644 --- a/linguistic/source/thesdsp.cxx +++ b/linguistic/source/thesdsp.cxx @@ -158,44 +158,43 @@ Sequence< Reference< XMeaning > > SAL_CALL const OUString *pImplNames = pEntry->aSvcImplNames.getConstArray(); Reference< XThesaurus > *pRef = pEntry->aSvcRefs.getArray(); - Reference< XMultiServiceFactory > xMgr( - comphelper::getProcessServiceFactory() ); - if (xMgr.is()) - { - // build service initialization argument - Sequence< Any > aArgs(1); - aArgs.getArray()[0] <<= GetPropSet(); + Reference< XComponentContext > xContext( + comphelper::getProcessComponentContext() ); + + // build service initialization argument + Sequence< Any > aArgs(1); + aArgs.getArray()[0] <<= GetPropSet(); - while (i < nLen && aMeanings.getLength() == 0) + while (i < nLen && aMeanings.getLength() == 0) + { + // create specific service via it's implementation name + Reference< XThesaurus > xThes; + try { - // create specific service via it's implementation name - Reference< XThesaurus > xThes; - try - { - xThes = Reference< XThesaurus >( - xMgr->createInstanceWithArguments( - pImplNames[i], aArgs ), UNO_QUERY ); - } - catch (uno::Exception &) - { - DBG_ASSERT( 0, "createInstanceWithArguments failed" ); - } - pRef[i] = xThes; - - if (xThes.is() && xThes->hasLocale( rLocale )) - aMeanings = xThes->queryMeanings( aChkWord, rLocale, rProperties ); - - pEntry->nLastTriedSvcIndex = (sal_Int16) i; - ++i; + xThes = Reference< XThesaurus >( + xContext->getServiceManager()->createInstanceWithArgumentsAndContext( + pImplNames[i], aArgs, xContext ), + UNO_QUERY ); } - - // if language is not supported by any of the services - // remove it from the list. - if (i == nLen && aMeanings.getLength() == 0) + catch (uno::Exception &) { - if (!SvcListHasLanguage( pEntry->aSvcRefs, rLocale )) - aSvcMap.erase( nLanguage ); + DBG_ASSERT( 0, "createInstanceWithArguments failed" ); } + pRef[i] = xThes; + + if (xThes.is() && xThes->hasLocale( rLocale )) + aMeanings = xThes->queryMeanings( aChkWord, rLocale, rProperties ); + + pEntry->nLastTriedSvcIndex = (sal_Int16) i; + ++i; + } + + // if language is not supported by any of the services + // remove it from the list. + if (i == nLen && aMeanings.getLength() == 0) + { + if (!SvcListHasLanguage( pEntry->aSvcRefs, rLocale )) + aSvcMap.erase( nLanguage ); } } } |