summaryrefslogtreecommitdiff
path: root/linguistic/source/spelldsp.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-05-13 15:13:34 +0200
committerNoel Grandin <noel@peralex.com>2013-05-14 08:08:26 +0200
commit0fd6fc3776ada4682e7286f9a0aaaf4c07b42643 (patch)
treee09685e233909aa2220f224664b68acc2443992b /linguistic/source/spelldsp.cxx
parent0394cb37a2d378511f265004b285fd93df37e5ca (diff)
fdo#46808, Convert some XMultiServiceFactory to XComponentContext
Change-Id: Ia66283321d4d18d929b2e3406ad420627f73a3fd
Diffstat (limited to 'linguistic/source/spelldsp.cxx')
-rw-r--r--linguistic/source/spelldsp.cxx240
1 files changed, 118 insertions, 122 deletions
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 );
}
}