diff options
author | Rüdiger Timm <rt@openoffice.org> | 2004-06-17 15:14:18 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2004-06-17 15:14:18 +0000 |
commit | c9f8ab0555586e9fb33878489a638cc6078d2be1 (patch) | |
tree | 22a9bab266fa908adb63eecca476827a96543438 /linguistic | |
parent | 3363660d80bba0d6cca5fe889b18c9b013333add (diff) |
INTEGRATION: CWS os30 (1.2.78); FILE MERGED
2004/03/10 14:14:01 tl 1.2.78.2: #i11655# adding entries from user-dictionaries to suggestion list for misspelled words
2004/03/10 13:59:23 tl 1.2.78.1: #i11655# adding entries from user-dictionaries to suggestion list for misspelled words
Diffstat (limited to 'linguistic')
-rw-r--r-- | linguistic/source/spelldta.cxx | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/linguistic/source/spelldta.cxx b/linguistic/source/spelldta.cxx index 15977792e9c8..c0ede9d6d570 100644 --- a/linguistic/source/spelldta.cxx +++ b/linguistic/source/spelldta.cxx @@ -2,9 +2,9 @@ * * $RCSfile: spelldta.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: hr $ $Date: 2003-03-26 12:51:42 $ + * last change: $Author: rt $ $Date: 2004-06-17 16:14:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,6 +65,7 @@ #include <com/sun/star/linguistic2/SpellFailure.hpp> #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> +#include <com/sun/star/linguistic2/XDictionary1.hpp> #ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT #include <tools/debug.hxx> @@ -76,6 +77,8 @@ #include <osl/mutex.hxx> #endif +#include <vector> + #include "spelldta.hxx" #include "lngsvcmgr.hxx" @@ -163,6 +166,51 @@ BOOL SeqHasEntry( } +void SearchSimilarText( const OUString &rText, INT16 nLanguage, + Reference< XDictionaryList > &xDicList, + std::vector< OUString > & rDicListProps ) +{ + if (!xDicList.is()) + return; + + const uno::Sequence< Reference< XDictionary > > + aDics( xDicList->getDictionaries() ); + const Reference< XDictionary > + *pDic = aDics.getConstArray(); + INT32 nDics = xDicList->getCount(); + + for (INT32 i = 0; i < nDics; i++) + { + Reference< XDictionary1 > xDic( pDic[i], UNO_QUERY ); + + DictionaryType eType = xDic->getDictionaryType(); + INT16 nLang = xDic->getLanguage(); + + if ( xDic.is() && xDic->isActive() + && (nLang == nLanguage || nLang == LANGUAGE_NONE) ) + { + DBG_ASSERT( eType != DictionaryType_MIXED, + "unexpected dictionary type" ); + const Sequence< Reference< XDictionaryEntry > > aEntries = xDic->getEntries(); + const Reference< XDictionaryEntry > *pEntries = aEntries.getConstArray(); + INT32 nLen = aEntries.getLength(); + for (INT32 k = 0; k < nLen; ++k) + { + String aEntryTxt; + if (pEntries[k].is()) + { + aEntryTxt = pEntries[k]->getDictionaryWord(); + // remove characters used to determine hyphenation positions + aEntryTxt.EraseAllChars( '=' ); + } + if (aEntryTxt.Len() > 0 && LevDistance( rText, aEntryTxt ) <= 2) + rDicListProps.push_back( aEntryTxt ); + } + } + } +} + + void SeqRemoveNegEntries( Sequence< OUString > &rSeq, Reference< XDictionaryList > &rxDicList, INT16 nLanguage ) |