summaryrefslogtreecommitdiff
path: root/linguistic
diff options
context:
space:
mode:
authorThomas Lange <tl@openoffice.org>2001-05-16 09:47:15 +0000
committerThomas Lange <tl@openoffice.org>2001-05-16 09:47:15 +0000
commited3212bbd6c5eb7a93e3f51d29dde4d4fe8c2671 (patch)
tree8e4af1c6b0168298b54b0f91198999fc27f81d1c /linguistic
parent113915371db37040407a3553fa7f32c8b914a93b (diff)
#86533# linguistic startup/file access optimization
Diffstat (limited to 'linguistic')
-rw-r--r--linguistic/source/hyphdsp.cxx19
-rw-r--r--linguistic/source/lngsvcmgr.cxx96
-rw-r--r--linguistic/source/spelldsp.cxx39
-rw-r--r--linguistic/source/thesdsp.cxx31
4 files changed, 161 insertions, 24 deletions
diff --git a/linguistic/source/hyphdsp.cxx b/linguistic/source/hyphdsp.cxx
index 812caec2e3e8..d552b479d0c6 100644
--- a/linguistic/source/hyphdsp.cxx
+++ b/linguistic/source/hyphdsp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: hyphdsp.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: tl $ $Date: 2001-01-29 14:15:07 $
+ * last change: $Author: tl $ $Date: 2001-05-16 10:44:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -384,6 +384,11 @@ Reference< XHyphenatedWord > SAL_CALL
pEntry->aFlags.nLastTriedSvcIndex = i;
++i;
+
+ // if language is not supported by the services
+ // remove it from the list.
+ if (rHyph.is() && !rHyph->hasLocale( rLocale ))
+ aSvcList.Remove( nLanguage );
}
}
} // if (xEntry.is())
@@ -489,6 +494,11 @@ Reference< XHyphenatedWord > SAL_CALL
pEntry->aFlags.nLastTriedSvcIndex = i;
++i;
+
+ // if language is not supported by the services
+ // remove it from the list.
+ if (rHyph.is() && !rHyph->hasLocale( rLocale ))
+ aSvcList.Remove( nLanguage );
}
}
} // if (xEntry.is())
@@ -592,6 +602,11 @@ Reference< XPossibleHyphens > SAL_CALL
pEntry->aFlags.nLastTriedSvcIndex = i;
++i;
+
+ // if language is not supported by the services
+ // remove it from the list.
+ if (rHyph.is() && !rHyph->hasLocale( rLocale ))
+ aSvcList.Remove( nLanguage );
}
}
} // if (xEntry.is())
diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx
index 45ae6505de08..3cf1edacf22d 100644
--- a/linguistic/source/lngsvcmgr.cxx
+++ b/linguistic/source/lngsvcmgr.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: lngsvcmgr.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: tl $ $Date: 2001-02-27 14:29:18 $
+ * last change: $Author: tl $ $Date: 2001-05-16 10:46:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -165,7 +165,7 @@ static Sequence< Locale > GetAvailLocales(
DBG_ERROR( "interface not supported by service" );
}
- // build returnes sequence
+ // build return sequence
INT16 nLanguages = aLanguages.Count();
aRes.realloc( nLanguages );
Locale *pRes = aRes.getArray();
@@ -270,8 +270,7 @@ static void SetAvailableServiceLists( LinguDispatcher &rDispatcher,
void SetAvailableCfgServiceLists( LinguDispatcher &rDispatcher,
const SvcInfoArray &rAvailSvcs )
{
- String aRoot( String::CreateFromAscii( "Office.Linguistic/ServiceManager" ) );
- SvtLinguConfigItem aCfg( aRoot );
+ SvtLinguConfigItem aCfg( A2OU( "Office.Linguistic/ServiceManager" ) );
// get list of nodenames to look at for their service list
const char *pEntryName = 0;
@@ -885,25 +884,88 @@ void LngSvcMgr::GetAvailableThesSvcs_Impl()
void LngSvcMgr::SetCfgServiceLists( SpellCheckerDispatcher &rSpellDsp )
{
- if (!pAvailSpellSvcs)
- GetAvailableSpellSvcs_Impl();
- SetAvailableCfgServiceLists( rSpellDsp, *pAvailSpellSvcs );
+ SvtLinguConfigItem aCfg( A2OU( "Office.Linguistic/ServiceManager/SpellCheckerList" ) );
+
+ Sequence< OUString > aNames( aCfg.GetNodeNames( OUString() ) );
+ const OUString *pNames = aNames.getConstArray();
+ INT32 nLen = aNames.getLength();
+
+ Sequence< Any > aValues( aCfg.GetProperties( aNames ) );
+ if (nLen && nLen == aValues.getLength())
+ {
+ const Any *pValues = aValues.getConstArray();
+ for (INT32 i = 0; i < nLen; ++i)
+ {
+ Sequence< OUString > aSvcImplNames;
+ if (pValues[i] >>= aSvcImplNames)
+ {
+#ifdef DEBUG
+ INT32 nSvcs = aSvcImplNames.getLength();
+ const OUString *pSvcImplNames = aSvcImplNames.getConstArray();
+#endif
+ Locale aLocale( CreateLocale( ConvertIsoStringToLanguage(pNames[i]) ) );
+ rSpellDsp.SetServiceList( aLocale, aSvcImplNames );
+ }
+ }
+ }
}
void LngSvcMgr::SetCfgServiceLists( HyphenatorDispatcher &rHyphDsp )
{
- if (!pAvailHyphSvcs)
- GetAvailableHyphSvcs_Impl();
- SetAvailableCfgServiceLists( rHyphDsp, *pAvailHyphSvcs );
+ SvtLinguConfigItem aCfg( A2OU( "Office.Linguistic/ServiceManager/HyphenatorList" ) );
+
+ Sequence< OUString > aNames( aCfg.GetNodeNames( OUString() ) );
+ const OUString *pNames = aNames.getConstArray();
+ INT32 nLen = aNames.getLength();
+
+ Sequence< Any > aValues( aCfg.GetProperties( aNames ) );
+ if (nLen && nLen == aValues.getLength())
+ {
+ Sequence< OUString > aSvcImplNames( 1 );
+ OUString *pSvcImplNames = aSvcImplNames.getArray();
+
+ const Any *pValues = aValues.getConstArray();
+ for (INT32 i = 0; i < nLen; ++i)
+ {
+ OUString aSvcImplName;
+ if (pValues[i] >>= aSvcImplName)
+ {
+ pSvcImplNames[0] = aSvcImplName;
+ Locale aLocale( CreateLocale( ConvertIsoStringToLanguage(pNames[i]) ) );
+ rHyphDsp.SetServiceList( aLocale, aSvcImplNames );
+ }
+ }
+ }
}
void LngSvcMgr::SetCfgServiceLists( ThesaurusDispatcher &rThesDsp )
{
- if (!pAvailThesSvcs)
- GetAvailableThesSvcs_Impl();
- SetAvailableCfgServiceLists( rThesDsp, *pAvailThesSvcs );
+ SvtLinguConfigItem aCfg( A2OU( "Office.Linguistic/ServiceManager/ThesaurusList" ) );
+
+ Sequence< OUString > aNames( aCfg.GetNodeNames( OUString() ) );
+ const OUString *pNames = aNames.getConstArray();
+ INT32 nLen = aNames.getLength();
+
+ Sequence< Any > aValues( aCfg.GetProperties( aNames ) );
+ if (nLen && nLen == aValues.getLength())
+ {
+ const Any *pValues = aValues.getConstArray();
+ for (INT32 i = 0; i < nLen; ++i)
+ {
+ Sequence< OUString > aSvcImplNames;
+ if (pValues[i] >>= aSvcImplNames)
+ {
+#ifdef DEBUG
+ INT32 nSvcs = aSvcImplNames.getLength();
+ const OUString *pSvcImplNames = aSvcImplNames.getConstArray();
+#endif
+ Locale aLocale( CreateLocale( ConvertIsoStringToLanguage(pNames[i]) ) );
+ rThesDsp.SetServiceList( aLocale, aSvcImplNames );
+ }
+ }
+ }
}
@@ -1176,8 +1238,7 @@ BOOL LngSvcMgr::SaveCfgSvcs( const String &rServiceName )
if (pDsp && aLocales.getLength())
{
- String aRoot( String::CreateFromAscii( "Office.Linguistic/ServiceManager" ) );
- SvtLinguConfigItem aCfg( aRoot );
+ SvtLinguConfigItem aCfg( A2OU( "Office.Linguistic/ServiceManager" ) );
INT32 nLen = aLocales.getLength();
const Locale *pLocale = aLocales.getConstArray();
@@ -1314,8 +1375,7 @@ Sequence< OUString > SAL_CALL
INT16 nLanguage = LocaleToLanguage( rLocale );
String aCfgLocale( ConvertLanguageToIsoString( nLanguage ) );
- String aRoot( String::CreateFromAscii( "Office.Linguistic/ServiceManager" ) );
- SvtLinguConfigItem aCfg( aRoot );
+ SvtLinguConfigItem aCfg( A2OU( "Office.Linguistic/ServiceManager" ) );
Sequence< Any > aValues;
Sequence< OUString > aName( 1 );
diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx
index cc88db43f5f5..2677736a1bee 100644
--- a/linguistic/source/spelldsp.cxx
+++ b/linguistic/source/spelldsp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: spelldsp.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: tl $ $Date: 2001-02-27 16:10:29 $
+ * last change: $Author: tl $ $Date: 2001-05-16 10:46:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -109,6 +109,25 @@ using namespace linguistic;
///////////////////////////////////////////////////////////////////////////
+static BOOL SvcListHasLanguage(
+ const Sequence< Reference< XSpellChecker1 > > &rRefs,
+ INT16 nLanguage )
+{
+ BOOL bHasLanguage = FALSE;
+
+ const Reference< XSpellChecker1 > *pRef = rRefs.getConstArray();
+ INT32 nLen = rRefs.getLength();
+ for (INT32 k = 0; k < nLen && !bHasLanguage; ++k)
+ {
+ if (pRef[k].is())
+ bHasLanguage = pRef[k]->hasLanguage( nLanguage );
+ }
+
+ return bHasLanguage;
+}
+
+///////////////////////////////////////////////////////////////////////////
+
SeqLangSvcEntry_Spell::~SeqLangSvcEntry_Spell()
{
@@ -400,6 +419,14 @@ BOOL SpellCheckerDispatcher::isValid_Impl(
pEntry->aFlags.nLastTriedSvcIndex = i;
++i;
}
+
+ // if language is not supported by any of the services
+ // remove it from the list.
+ if (i == nLen)
+ {
+ if (!SvcListHasLanguage( pEntry->aSvc1Refs, nLanguage ))
+ aSvcList.Remove( nLanguage );
+ }
}
}
@@ -638,6 +665,14 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
pEntry->aFlags.nLastTriedSvcIndex = i;
++i;
}
+
+ // if language is not supported by any of the services
+ // remove it from the list.
+ if (i == nLen)
+ {
+ if (!SvcListHasLanguage( pEntry->aSvc1Refs, nLanguage ))
+ aSvcList.Remove( nLanguage );
+ }
}
}
diff --git a/linguistic/source/thesdsp.cxx b/linguistic/source/thesdsp.cxx
index 41f696c999fa..4b874da38bd0 100644
--- a/linguistic/source/thesdsp.cxx
+++ b/linguistic/source/thesdsp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: thesdsp.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: tl $ $Date: 2001-02-27 16:11:15 $
+ * last change: $Author: tl $ $Date: 2001-05-16 10:47:15 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,6 +97,25 @@ using namespace linguistic;
///////////////////////////////////////////////////////////////////////////
+static BOOL SvcListHasLanguage(
+ const Sequence< Reference< XThesaurus > > &rRefs,
+ const Locale &rLocale )
+{
+ BOOL bHasLanguage = FALSE;
+
+ const Reference< XThesaurus > *pRef = rRefs.getConstArray();
+ INT32 nLen = rRefs.getLength();
+ for (INT32 k = 0; k < nLen && !bHasLanguage; ++k)
+ {
+ if (pRef[k].is())
+ bHasLanguage = pRef[k]->hasLocale( rLocale );
+ }
+
+ return bHasLanguage;
+}
+
+///////////////////////////////////////////////////////////////////////////
+
SeqLangSvcEntry_Thes::~SeqLangSvcEntry_Thes()
{
}
@@ -243,6 +262,14 @@ Sequence< Reference< XMeaning > > SAL_CALL
pEntry->aFlags.nLastTriedSvcIndex = 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 ))
+ aSvcList.Remove( nLanguage );
+ }
}
}
}