diff options
Diffstat (limited to 'linguistic/source')
-rw-r--r-- | linguistic/source/lngopt.cxx | 389 | ||||
-rw-r--r-- | linguistic/source/lngopt.hxx | 139 | ||||
-rw-r--r-- | linguistic/source/lngsvcmgr.cxx | 196 | ||||
-rw-r--r-- | linguistic/source/lngsvcmgr.hxx | 11 |
4 files changed, 463 insertions, 272 deletions
diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx index 269be3047924..038f13ff68ba 100644 --- a/linguistic/source/lngopt.cxx +++ b/linguistic/source/lngopt.cxx @@ -2,9 +2,9 @@ * * $RCSfile: lngopt.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: tl $ $Date: 2000-11-22 15:56:01 $ + * last change: $Author: tl $ $Date: 2000-11-28 03:12:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -113,7 +113,7 @@ using namespace com::sun::star::registry; static const char cLocaleDelim = '-'; -static INT16 CfgLocaleStrToLanguage( const OUString &rCfgLocaleStr ) +INT16 CfgLocaleStrToLanguage( const OUString &rCfgLocaleStr ) { INT16 nRes = LANGUAGE_NONE; if (rCfgLocaleStr.getLength()) @@ -135,7 +135,7 @@ static INT16 CfgLocaleStrToLanguage( const OUString &rCfgLocaleStr ) } -static const OUString LanguageToCfgLocaleStr( INT16 nLanguage ) +const OUString LanguageToCfgLocaleStr( INT16 nLanguage ) { static const OUString aLocaleDelim( cLocaleDelim ); OUString aRes; @@ -153,7 +153,7 @@ static const OUString LanguageToCfgLocaleStr( INT16 nLanguage ) } -static INT16 CfgAnyToLanguage( const Any &rVal ) +INT16 CfgAnyToLanguage( const Any &rVal ) { OUString aTmp; rVal >>= aTmp; @@ -164,77 +164,7 @@ static INT16 CfgAnyToLanguage( const Any &rVal ) /////////////////////////////////////////////////////////////////////////// -static void GetSeqLangSvcList( const Any &rVal ) -{ - Reference< XNameAccess > xNameAcc; - rVal >>= xNameAcc; - if (xNameAcc.is()) - { - const Sequence< OUString > aNames( xNameAcc->getElementNames() ); - INT32 nLen = aNames.getLength(); - if (nLen) - { - const OUString *pName = aNames.getConstArray(); - for (INT32 i = 0; i < nLen; ++i) - { - Any aTmp( xNameAcc->getByName( pName[i] ) ); - if (aTmp.hasValue()) - { - Sequence< OUString > aSvcNames; - aTmp >>= aSvcNames; - - INT32 nSvcs = aSvcNames.getLength(); - if (nSvcs) - { - const OUString *pSvcName = aSvcNames.getConstArray(); - for (INT32 j = 0; j < nSvcs; ++j) - { - OUString aImplName( pSvcName[i] ); - - // TL TODO: services needs to be set when new - // configuration dialogue is available - } - } - } - } - } - } -} - - -static void GetSeqLangSvc( const Any &rVal ) -{ - Reference< XNameAccess > xNameAcc; - rVal >>= xNameAcc; - if (xNameAcc.is()) - { - const Sequence< OUString > aNames( xNameAcc->getElementNames() ); - INT32 nLen = aNames.getLength(); - if (nLen) - { - const OUString *pName = aNames.getConstArray(); - for (INT32 i = 0; i < nLen; ++i) - { - Any aTmp( xNameAcc->getByName( pName[i] ) ); - if (aTmp.hasValue()) - { - OUString aImplName; - aTmp >>= aImplName; - - // TL TODO: service needs to be set when new - // configuration dialogue is available - } - } - } - } -} - - -/////////////////////////////////////////////////////////////////////////// - - -LinguOptions::LinguOptionsData::LinguOptionsData() : - ConfigItem( A2OU("Office.Linguistic") ) +LinguOptionsData::LinguOptionsData() { // get initial language to use (in case that it is not set later) nDefaultLanguage = ::GetSystemLanguage(); @@ -271,104 +201,138 @@ LinguOptions::LinguOptionsData::LinguOptionsData() : bIsStdSpell = bIsStdThes = bIsStdHyph = FALSE; + bIsModified = FALSE; + + aSaveTimer.SetTimeout( 10000 ); + aSaveTimer.SetTimeoutHdl( LINK( this, LinguOptionsData, TimeOut )); LoadConfig(); } -Sequence< OUString > LinguOptions::LinguOptionsData::GetPropertyNames() +Sequence< OUString > GetPropertyNames( INT16 nCfgItem ) { - static const char * aPropNames[] = + static const char * aPropNames1[] = + { + "DefaultLocale", // 0 + "DictionaryList/ActiveDictionaries", // 1 + "DictionaryList/IsUseDictionaryList", // 2 + "IsIgnoreControlCharacters", // 3 + "IsGermanPreReform", // 4 + "DefaultLocale_CJK", // 5 + "DefaultLocale_CTL", // 6 + 0 + }; + + static const char * aPropNames2[] = + { + "IsSpellUpperCase", // 5 + "IsSpellWithDigits", // 6 + "IsSpellCapitalization", // 7 + "IsSpellAuto", // 8 + "IsSpellSpecial", // 9 + "IsSpellInAllLocales", // 10 + "IsHideMarkings", // 11 + "IsReverseDirection", // 12 + 0 + }; + + static const char * aPropNames3[] = + { + "MinLeading", // 13 + "MinTrailing", // 14 + "MinWordLength", // 15 + "IsHyphSpecial", // 16 + "IsHyphAuto", // 17 + 0 + }; + + static const char * aPropNames4[] = { - "General/DefaultLocale", // 0 - "General/DictionaryList/ActiveDictionaries", // 1 - "General/DictionaryList/IsUseDictionaryList", // 2 - "General/IsIgnoreControlCharacters", // 3 - "General/IsGermanPreReform", // 4 - "SpellChecking/IsSpellUpperCase", // 5 - "SpellChecking/IsSpellWithDigits", // 6 - "SpellChecking/IsSpellCapitalization", // 7 - "SpellChecking/IsSpellAuto", // 8 - "SpellChecking/IsSpellSpecial", // 9 - "SpellChecking/IsSpellInAllLocales", // 10 - "SpellChecking/IsHideMarkings", // 11 - "SpellChecking/IsReverseDirection", // 12 - "Hyphenation/MinLeading", // 13 - "Hyphenation/MinTrailing", // 14 - "Hyphenation/MinWordLength", // 15 - "Hyphenation/IsHyphSpecial", // 16 - "Hyphenation/IsHyphAuto", // 17 - "ExternalLinguistic/OtherLinguIndex", // 18 - "ExternalLinguistic/IsUseStandardSpellChecker", // 19 - "ExternalLinguistic/IsUseStandardHyphenator", // 20 - "ExternalLinguistic/IsUseStandardThesaurus", // 21 - "ServiceManager/SpellCheckerList", // 22 - "ServiceManager/ThesaurusList", // 23 - "ServiceManager/HyphenatorList", // 24 - "General/DefaultLocale_CJK", // 25 - "General/DefaultLocale_CTL" // 26 + "OtherLinguIndex", // 18 + "IsUseStandardSpellChecker", // 19 + "IsUseStandardHyphenator", // 20 + "IsUseStandardThesaurus", // 21 + 0 }; - INT32 nCount = sizeof(aPropNames) / sizeof(aPropNames[0]); - Sequence< OUString > aNames( nCount ); + static const char** aPropNames[ 4 ] = { + aPropNames1, aPropNames2, aPropNames3, aPropNames4 }; + + const char** ppPropName = aPropNames[ nCfgItem ]; + + Sequence< OUString > aNames( 10 ); OUString *pNames = aNames.getArray(); - for(INT32 i = 0; i < nCount; ++i) + for( INT32 i = 0; *ppPropName; ++i, ++ppPropName ) { - pNames[i] = A2OU( aPropNames[i] ); + pNames[i] = A2OU( *ppPropName ); } + aNames.realloc( i ); return aNames; } +static const char* aRootNames[ 4 ] = { + "Office.Linguistic/General", + "Office.Linguistic/SpellChecking", + "Office.Linguistic/Hyphenation", + "Office.Linguistic/ExternalLinguistic" }; + -BOOL LinguOptions::LinguOptionsData::LoadConfig() + +BOOL LinguOptionsData::LoadConfig() { BOOL bRes = FALSE; - Sequence< OUString > aNames = GetPropertyNames(); - INT32 nProps = aNames.getLength(); - const Sequence< Any > aValues = GetProperties( aNames ); - EnableNotification( aNames ); - - if (nProps && aValues.getLength() == nProps) + for( INT16 nCfgItem = 0; nCfgItem < 4; ++nCfgItem ) { - const Any *pValue = aValues.getConstArray(); - for (INT32 i = 0; i < nProps; ++i) + Sequence< OUString > aNames = GetPropertyNames( nCfgItem ); + INT32 nProps = aNames.getLength(); + + LinguOptConfig aCfg( String::CreateFromAscii( aRootNames[ nCfgItem ])); + + const Sequence< Any > aValues = aCfg.GetProperties( aNames ); + + if (nProps && aValues.getLength() == nProps) { - const Any &rVal = pValue[i]; - if (rVal.hasValue()) + const Any *pValue = aValues.getConstArray(); + INT16 nCfgOff = 10 * nCfgItem; + for (INT32 i = 0; i < nProps; ++i) { - switch (i) - { - case 0: nDefaultLanguage = CfgAnyToLanguage( rVal ); break; - case 1: rVal >>= aActiveDics; break; - case 2: rVal >>= bIsUseDictionaryList; break; - case 3: rVal >>= bIsIgnoreControlCharacters; break; - case 4: rVal >>= bIsGermanPreReform; break; - case 5: rVal >>= bIsSpellUpperCase; break; - case 6: rVal >>= bIsSpellWithDigits; break; - case 7: rVal >>= bIsSpellCapitalization; break; - case 8: rVal >>= bIsSpellAuto; break; - case 9: rVal >>= bIsSpellSpecial; break; - case 10: rVal >>= bIsSpellInAllLanguages; break; - case 11: rVal >>= bIsSpellHideMarkings; break; - case 12: rVal >>= bIsSpellReverse; break; - case 13: rVal >>= nHyphMinLeading; break; - case 14: rVal >>= nHyphMinTrailing; break; - case 15: rVal >>= nHyphMinWordLength; break; - case 16: rVal >>= bIsHyphSpecial; break; - case 17: rVal >>= bIsHyphAuto; break; - case 18: rVal >>= nOtherIndex; break; - case 19: rVal >>= bIsStdSpell; break; - case 20: rVal >>= bIsStdHyph; break; - case 21: rVal >>= bIsStdThes; break; - case 22: GetSeqLangSvcList( rVal ); break; - case 23: GetSeqLangSvcList( rVal ); break; - case 24: GetSeqLangSvc( rVal ); break; - case 25: nDefaultLanguage_CJK = CfgAnyToLanguage( rVal ); break; - case 26: nDefaultLanguage_CTL = CfgAnyToLanguage( rVal ); break; - default: - DBG_ERROR( "unexpected case" ); - } + const Any &rVal = pValue[i]; + if( rVal.hasValue() ) + switch ( i + nCfgOff ) + { + case 0: nDefaultLanguage = CfgAnyToLanguage( rVal ); break; + case 1: rVal >>= aActiveDics; break; + case 2: rVal >>= bIsUseDictionaryList; break; + case 3: rVal >>= bIsIgnoreControlCharacters; break; + case 4: rVal >>= bIsGermanPreReform; break; + case 5: nDefaultLanguage_CJK = CfgAnyToLanguage( rVal ); break; + case 6: nDefaultLanguage_CTL = CfgAnyToLanguage( rVal ); break; + + case 10: rVal >>= bIsSpellUpperCase; break; + case 11: rVal >>= bIsSpellWithDigits; break; + case 12: rVal >>= bIsSpellCapitalization; break; + case 13: rVal >>= bIsSpellAuto; break; + case 14: rVal >>= bIsSpellSpecial; break; + case 15: rVal >>= bIsSpellInAllLanguages; break; + case 16: rVal >>= bIsSpellHideMarkings; break; + case 17: rVal >>= bIsSpellReverse; break; + + case 20: rVal >>= nHyphMinLeading; break; + case 21: rVal >>= nHyphMinTrailing; break; + case 22: rVal >>= nHyphMinWordLength; break; + case 23: rVal >>= bIsHyphSpecial; break; + case 24: rVal >>= bIsHyphAuto; break; + + case 30: rVal >>= nOtherIndex; break; + case 31: rVal >>= bIsStdSpell; break; + case 32: rVal >>= bIsStdHyph; break; + case 33: rVal >>= bIsStdThes; break; + + default: + DBG_ERROR( "unexpected case" ); + } } } @@ -380,72 +344,85 @@ BOOL LinguOptions::LinguOptionsData::LoadConfig() } -BOOL LinguOptions::LinguOptionsData::SaveConfig() +BOOL LinguOptionsData::SaveConfig() { - const Sequence< OUString > aNames = GetPropertyNames(); - INT32 nProps = aNames.getLength(); - Sequence< Any > aValues( aNames.getLength() ); - Any *pValue = aValues.getArray(); + if( !bIsModified ) + return TRUE; + BOOL bRet = FALSE; const Type &rBOOL = ::getBooleanCppuType(); const Type &rINT16 = ::getCppuType( (INT16 *) NULL ); - for (INT32 i = 0; i < nProps; ++i) + for( INT16 nCfgItem = 0; nCfgItem < 4; ++nCfgItem ) { - Any &rVal = pValue[i]; - switch (i) + const Sequence< OUString > aNames = GetPropertyNames( nCfgItem ); + INT32 nProps = aNames.getLength(); + Sequence< Any > aValues( aNames.getLength() ); + Any *pValue = aValues.getArray(); + + switch( nCfgItem ) { - case 0: + case 0: { OUString aTmp( LanguageToCfgLocaleStr( nDefaultLanguage ) ); - rVal = makeAny( aTmp ); - break; - } - case 1: rVal = makeAny( aActiveDics ); break; - case 2: rVal.setValue( &bIsUseDictionaryList, rBOOL ); break; - case 3: rVal.setValue( &bIsIgnoreControlCharacters, rBOOL ); break; - case 4: rVal.setValue( &bIsGermanPreReform, rBOOL ); break; - case 5: rVal.setValue( &bIsSpellUpperCase, rBOOL ); break; - case 6: rVal.setValue( &bIsSpellWithDigits, rBOOL ); break; - case 7: rVal.setValue( &bIsSpellCapitalization, rBOOL ); break; - case 8: rVal.setValue( &bIsSpellAuto, rBOOL ); break; - case 9: rVal.setValue( &bIsSpellSpecial, rBOOL ); break; - case 10: rVal.setValue( &bIsSpellInAllLanguages, rBOOL ); break; - case 11: rVal.setValue( &bIsSpellHideMarkings, rBOOL ); break; - case 12: rVal.setValue( &bIsSpellReverse, rBOOL ); break; - case 13: rVal.setValue( &nHyphMinLeading, rINT16 ); break; - case 14: rVal.setValue( &nHyphMinTrailing, rINT16 ); break; - case 15: rVal.setValue( &nHyphMinWordLength, rINT16 ); break; - case 16: rVal.setValue( &bIsHyphSpecial, rBOOL ); break; - case 17: rVal.setValue( &bIsHyphAuto, rBOOL ); break; - case 18: rVal.setValue( &nOtherIndex, rINT16 ); break; - case 19: rVal.setValue( &bIsStdSpell, rBOOL ); break; - case 20: rVal.setValue( &bIsStdHyph, rBOOL ); break; - case 21: rVal.setValue( &bIsStdThes, rBOOL ); break; - case 22: break; - case 23: break; - case 24: break; - case 25: - { - OUString aTmp( LanguageToCfgLocaleStr( nDefaultLanguage_CJK ) ); - rVal = makeAny( aTmp ); - break; - } - case 26: - { - OUString aTmp( LanguageToCfgLocaleStr( nDefaultLanguage_CTL ) ); - rVal = makeAny( aTmp ); - break; + *pValue++ = makeAny( aTmp ); + *pValue++ = makeAny( aActiveDics ); + pValue->setValue( &bIsUseDictionaryList, rBOOL ); + ++pValue; + pValue->setValue( &bIsIgnoreControlCharacters, rBOOL ); + ++pValue; + pValue->setValue( &bIsGermanPreReform, rBOOL ); + ++pValue; + + aTmp = LanguageToCfgLocaleStr( nDefaultLanguage_CJK ); + *pValue++ = makeAny( aTmp ); + + aTmp = LanguageToCfgLocaleStr( nDefaultLanguage_CTL ); + *pValue++ = makeAny( aTmp ); } - default: - DBG_ERROR( "unexpected case" ); + break; + case 1: + pValue->setValue( &bIsSpellUpperCase, rBOOL ); ++pValue; + pValue->setValue( &bIsSpellWithDigits, rBOOL ); ++pValue; + pValue->setValue( &bIsSpellCapitalization, rBOOL ); ++pValue; + pValue->setValue( &bIsSpellAuto, rBOOL ); ++pValue; + pValue->setValue( &bIsSpellSpecial, rBOOL ); ++pValue; + pValue->setValue( &bIsSpellInAllLanguages, rBOOL ); ++pValue; + pValue->setValue( &bIsSpellHideMarkings, rBOOL ); ++pValue; + pValue->setValue( &bIsSpellReverse, rBOOL ); ++pValue; + break; + case 2: + pValue->setValue( &nHyphMinLeading, rINT16 ); ++pValue; + pValue->setValue( &nHyphMinTrailing, rINT16 ); ++pValue; + pValue->setValue( &nHyphMinWordLength, rINT16 );++pValue; + pValue->setValue( &bIsHyphSpecial, rBOOL ); ++pValue; + pValue->setValue( &bIsHyphAuto, rBOOL ); ++pValue; + break; + case 3: + pValue->setValue( &nOtherIndex, rINT16 ); ++pValue; + pValue->setValue( &bIsStdSpell, rBOOL ); ++pValue; + pValue->setValue( &bIsStdHyph, rBOOL ); ++pValue; + pValue->setValue( &bIsStdThes, rBOOL ); ++pValue; + break; } + + LinguOptConfig aCfg( String::CreateFromAscii( aRootNames[ nCfgItem ])); + bRet |= aCfg.PutProperties( aNames, aValues ); } - return PutProperties( aNames, aValues ); + if( bRet ) + bIsModified = FALSE; + + return bRet; } +IMPL_LINK( LinguOptionsData, TimeOut, Timer*, p ) +{ + SaveConfig(); + return 0; +} +/* void LinguOptions::LinguOptionsData::Notify( const Sequence< OUString >& rPropertyNames ) { DBG_ERROR("properties have been changed"); @@ -456,12 +433,12 @@ void LinguOptions::LinguOptionsData::Commit() { SaveConfig(); } - +*/ /////////////////////////////////////////////////////////////////////////// // static member intialization -LinguOptions::LinguOptionsData * LinguOptions::pData = NULL; +LinguOptionsData * LinguOptions::pData = NULL; LinguOptions::LinguOptions() @@ -590,7 +567,7 @@ BOOL LinguOptions::SetValue( Any &rOld, const Any &rVal, INT32 nWID ) } if (bRes) - pData->SetCfgItemModified(); + pData->SetModified(); return bRes; } @@ -735,7 +712,7 @@ void LinguOptions::SetCfgActiveDictionaries( } pData->aActiveDics.realloc( nLen ); - pData->SetCfgItemModified(); + pData->SetModified(); } } diff --git a/linguistic/source/lngopt.hxx b/linguistic/source/lngopt.hxx index 3c808bf88a79..4852667402ff 100644 --- a/linguistic/source/lngopt.hxx +++ b/linguistic/source/lngopt.hxx @@ -2,9 +2,9 @@ * * $RCSfile: lngopt.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: tl $ $Date: 2000-11-22 15:56:01 $ + * last change: $Author: tl $ $Date: 2000-11-28 03:12:44 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -100,6 +100,7 @@ #include <tools/solar.h> #endif +#include <vcl/timer.hxx> #include <svtools/itemprop.hxx> #include "misc.hxx" @@ -115,73 +116,93 @@ namespace com { namespace sun { namespace star { }}}; /////////////////////////////////////////////////////////////////////////// + +INT16 CfgLocaleStrToLanguage( const rtl::OUString &rCfgLocaleStr ); +const rtl::OUString LanguageToCfgLocaleStr( INT16 nLanguage ); +INT16 CfgAnyToLanguage( const com::sun::star::uno::Any &rVal ); + +/////////////////////////////////////////////////////////////////////////// // LinguOptions // This class represents all Linguistik relevant options. // -class LinguOptions +class LinguOptConfig : public utl::ConfigItem { - class LinguOptionsData : public utl::ConfigItem - { - com::sun::star::uno::Sequence< rtl::OUString > GetPropertyNames(); - - public: - ::vos::ORefCount aRefCount; // number of objects of this class - - ::com::sun::star::uno::Sequence< rtl::OUString > aActiveDics; - - // Hyphenator service specific options - INT16 nHyphMinLeading, - nHyphMinTrailing, - nHyphMinWordLength; - - // OtherLingu service specific option - INT16 nOtherIndex; // index of foreign Linguistik to use - - // misc options (non-service specific) - INT16 nDefaultLanguage; - INT16 nDefaultLanguage_CJK; - INT16 nDefaultLanguage_CTL; - - // spelling options (non-service specific) - BOOL bIsSpellSpecial; - BOOL bIsSpellInAllLanguages; - BOOL bIsSpellAuto; - BOOL bIsSpellHideMarkings; - BOOL bIsSpellReverse; - - // hyphenation options (non-service specific) - BOOL bIsHyphSpecial; - BOOL bIsHyphAuto; - - // common to SpellChecker, Hyphenator and Thesaurus service - BOOL bIsGermanPreReform; - BOOL bIsUseDictionaryList; - BOOL bIsIgnoreControlCharacters; - - // SpellChecker service specific options - BOOL bIsSpellWithDigits, - bIsSpellUpperCase, - bIsSpellCapitalization; - - // OtherLingu service specific options - BOOL bIsStdSpell; - BOOL bIsStdHyph; // TRUE if foreign Hyphenator should not be used - BOOL bIsStdThes; // TRUE if foreign SpellChecker should not be used +public: + LinguOptConfig( const String& rPath ) : + ConfigItem( rPath ) + {} + ConfigItem::GetProperties; + ConfigItem::PutProperties; +}; - LinguOptionsData(); - BOOL LoadConfig(); - BOOL SaveConfig(); - // ConfigItem - virtual void Notify( const com::sun::star::uno::Sequence< - rtl::OUString >& rPropertyNames ); - virtual void Commit(); +struct LinguOptionsData +{ + Timer aSaveTimer; + ::vos::ORefCount aRefCount; // number of objects of this class + + ::com::sun::star::uno::Sequence< rtl::OUString > aActiveDics; + + // Hyphenator service specific options + INT16 nHyphMinLeading, + nHyphMinTrailing, + nHyphMinWordLength; + + // OtherLingu service specific option + INT16 nOtherIndex; // index of foreign Linguistik to use + + // misc options (non-service specific) + INT16 nDefaultLanguage; + INT16 nDefaultLanguage_CJK; + INT16 nDefaultLanguage_CTL; + + // spelling options (non-service specific) + BOOL bIsSpellSpecial; + BOOL bIsSpellInAllLanguages; + BOOL bIsSpellAuto; + BOOL bIsSpellHideMarkings; + BOOL bIsSpellReverse; + + // hyphenation options (non-service specific) + BOOL bIsHyphSpecial; + BOOL bIsHyphAuto; + + // common to SpellChecker, Hyphenator and Thesaurus service + BOOL bIsGermanPreReform; + BOOL bIsUseDictionaryList; + BOOL bIsIgnoreControlCharacters; + + // SpellChecker service specific options + BOOL bIsSpellWithDigits, + bIsSpellUpperCase, + bIsSpellCapitalization; + + // OtherLingu service specific options + BOOL bIsStdSpell; + BOOL bIsStdHyph; // TRUE if foreign Hyphenator should not be used + BOOL bIsStdThes; // TRUE if foreign SpellChecker should not be used + + BOOL bIsModified; // TRUE if data is changed + + LinguOptionsData(); + + BOOL LoadConfig(); + BOOL SaveConfig(); + + DECL_LINK( TimeOut, Timer* ); +/* virtual void Notify( const com::sun::star::uno::Sequence< + rtl::OUString >& rPropertyNames ); + virtual void Commit(); +*/ + inline void SetModified() + { bIsModified = TRUE; aSaveTimer.Start(); } +}; - inline void SetCfgItemModified() { SetModified(); } - }; +class LinguOptions +{ static LinguOptionsData *pData; diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx index b6b0fa0db761..4dfe18021b83 100644 --- a/linguistic/source/lngsvcmgr.cxx +++ b/linguistic/source/lngsvcmgr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: lngsvcmgr.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-11-17 12:37:40 $ + * last change: $Author: tl $ $Date: 2000-11-28 03:12:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -77,11 +77,15 @@ #ifndef _COM_SUN_STAR_LINGUISTIC2_XSUPPORTEDLOCALES_HPP_ #include <com/sun/star/linguistic2/XSupportedLocales.hpp> #endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif #include <com/sun/star/linguistic2/DictionaryListEventFlags.hpp> #include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp> #include "lngsvcmgr.hxx" +#include "lngopt.hxx" #include "misc.hxx" #include "spelldsp.hxx" #include "hyphdsp.hxx" @@ -440,7 +444,7 @@ BOOL LngSvcMgrListenerHelper::RemoveLngSvcEvtBroadcaster( LngSvcMgr::LngSvcMgr() : aEvtListeners ( GetLinguMutex() ) { - bDisposing = FALSE; + bIsModified = bDisposing = FALSE; pSpellDsp = 0; pHyphDsp = 0; @@ -450,6 +454,9 @@ LngSvcMgr::LngSvcMgr() : pHyphSvcs = 0; pThesSvcs = 0; pListenerHelper = 0; + + aSaveTimer.SetTimeout( 5000 ); + aSaveTimer.SetTimeoutHdl( LINK( this, LngSvcMgr, TimeOut )); } @@ -861,7 +868,7 @@ void SAL_CALL throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - +#ifdef NEVER // TL_TODO: // write code to access the configuration and set the following // variable accordingly @@ -871,15 +878,164 @@ void SAL_CALL if (bCfgChgSuccess && LANGUAGE_NONE != nLanguage) { if (0 == rServiceName.compareToAscii( SN_SPELLCHECKER )) + { + if (!xSpellDsp.is()) + GetSpellCheckerDsp_Impl(); pSpellDsp->SetServiceList( rLocale, rServiceImplNames ); + bIsModified = TRUE; + } else if (0 == rServiceName.compareToAscii( SN_HYPHENATOR )) + { + if (!xHyphDsp.is()) + GetHyphenatorDsp_Impl(); pHyphDsp->SetServiceList( rLocale, rServiceImplNames ); + bIsModified = TRUE; + } else if (0 == rServiceName.compareToAscii( SN_THESAURUS )) + { + if (!xThesDsp.is()) + GetThesaurusDsp_Impl(); pThesDsp->SetServiceList( rLocale, rServiceImplNames ); + bIsModified = TRUE; + } + if( bIsModified ) + aSaveTimer.Start(); + } +#endif +} + +static const char* aPropNames[] = { + "SpellCheckerList", + "ThesaurusList", + "HyphenatorList" +}; + + +IMPL_LINK( LngSvcMgr, TimeOut, Timer*, p ) +{ + if( bIsModified ) + { +#ifdef NEVER + Sequence< OUString > aNames( GetPropertyNames() ); + + INT32 nProps = aNames.getLength(); + Sequence< Any > aValues( aNames.getLength() ); + Any *pValue = aValues.getArray(); + + //... + + LinguOptConfig aCfg( String::CreateFromAscii( + "Office.Linguistic/ServiceManager" )); + aCfg.PutProperties( aNames, aValues ); + + bIsModified = FALSE; +#endif } + return 0; } +static Sequence< OUString > GetSeqLangSvcList( + const Locale& rLocale, + const Any &rVal ) +{ + Sequence< OUString > aRes; + + if (rVal.hasValue()) + { + int a=3; + } + + Reference< XNameAccess > xNameAcc; + rVal >>= xNameAcc; + if (xNameAcc.is()) + { + const Sequence< OUString > aNames( xNameAcc->getElementNames() ); + INT32 nLen = aNames.getLength(); + if (nLen) + { + INT16 nLanguage = LocaleToLanguage( rLocale ); + + const OUString *pName = aNames.getConstArray(); + for (INT32 i = 0; i < nLen; ++i) + { + INT16 nCfgLang = CfgLocaleStrToLanguage( pName[i] ); + + if (nLanguage != nCfgLang) + continue; + + Any aTmp( xNameAcc->getByName( pName[i] ) ); + if (aTmp.hasValue()) + { + Sequence< OUString > aSvcNames; + aTmp >>= aSvcNames; + + aRes = aSvcNames; +#ifdef DEBUG + INT32 nSvcs = aSvcNames.getLength(); + if (nSvcs) + { + const OUString *pSvcName = aSvcNames.getConstArray(); + for (INT32 j = 0; j < nSvcs; ++j) + { + OUString aImplName( pSvcName[i] ); + + // TL TODO: services needs to be set when new + // configuration dialogue is available + } + } +#endif + } + } + } + } + + return aRes; +} + + +static Sequence< OUString > GetSeqLangSvc( + const Locale& rLocale, + const Any &rVal ) +{ + Sequence< OUString > aRes; + + if (rVal.hasValue()) + { + int a=3; + } + Reference< XNameAccess > xNameAcc; + rVal >>= xNameAcc; + if (xNameAcc.is()) + { + const Sequence< OUString > aNames( xNameAcc->getElementNames() ); + INT32 nLen = aNames.getLength(); + if (nLen) + { + const OUString *pName = aNames.getConstArray(); + for (INT32 i = 0; i < nLen; ++i) + { + Any aTmp( xNameAcc->getByName( pName[i] ) ); + if (aTmp.hasValue()) + { + OUString aImplName; + aTmp >>= aImplName; + + // TL TODO: service needs to be set when new + // configuration dialogue is available + } + } + } + } + + return aRes; +} + + +/////////////////////////////////////////////////////////////////////////// + + + Sequence< OUString > SAL_CALL LngSvcMgr::getConfiguredServices( const OUString& rServiceName, @@ -887,7 +1043,37 @@ Sequence< OUString > SAL_CALL throw(RuntimeException) { MutexGuard aGuard( GetLinguMutex() ); - return Sequence< OUString > (); + + Sequence< OUString > aSvcImplNames; + + Sequence< OUString > aName( 1 ); + Sequence< Any > aValues( 1 ); + + LinguOptConfig aCfg( String::CreateFromAscii( + "Office.Linguistic/ServiceManager" ) ); + + OUString *pNames = aName.getArray(); + if ( 0 == rServiceName.compareToAscii( SN_SPELLCHECKER ) ) + { + pNames[0] = A2OU( aPropNames[0] ); + aValues = aCfg.GetProperties( aName ); + aSvcImplNames = GetSeqLangSvcList( rLocale, aValues.getConstArray()[0] ); // Spell + } + else if ( 0 == rServiceName.compareToAscii( SN_THESAURUS ) ) + { + pNames[0] = A2OU( aPropNames[1] ); + aValues = aCfg.GetProperties( aName ); + Any *pValue = aValues.getArray(); + aSvcImplNames = GetSeqLangSvcList( rLocale, aValues.getConstArray()[0] ); // Thes + } + else if ( 0 == rServiceName.compareToAscii( SN_HYPHENATOR ) ) + { + pNames[0] = A2OU( aPropNames[2] ); + aValues = aCfg.GetProperties( aName ); + aSvcImplNames = GetSeqLangSvc( rLocale, aValues.getConstArray()[0] ); // Hyph + } + + return aSvcImplNames; } diff --git a/linguistic/source/lngsvcmgr.hxx b/linguistic/source/lngsvcmgr.hxx index 78e627054a08..a0378b0e07c2 100644 --- a/linguistic/source/lngsvcmgr.hxx +++ b/linguistic/source/lngsvcmgr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: lngsvcmgr.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-11-17 12:37:40 $ + * last change: $Author: tl $ $Date: 2000-11-28 03:13:10 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,6 +84,8 @@ #include <com/sun/star/linguistic2/XLinguServiceManager.hpp> #endif +#include <vcl/timer.hxx> + #include "misc.hxx" #include "defs.hxx" @@ -133,7 +135,10 @@ class LngSvcMgr : SvcInfoArray * pHyphSvcs; SvcInfoArray * pThesSvcs; + Timer aSaveTimer; + BOOL bDisposing; + BOOL bIsModified; // disallow copy-constructor and assignment-operator for now LngSvcMgr(const LngSvcMgr &); @@ -151,6 +156,8 @@ class LngSvcMgr : void SetCfgServiceLists( HyphenatorDispatcher &rHyphDsp ); void SetCfgServiceLists( ThesaurusDispatcher &rThesDsp ); + DECL_LINK( TimeOut, Timer* ); + public: LngSvcMgr(); virtual ~LngSvcMgr(); |