diff options
author | Tomaž Vajngerl <quikee@gmail.com> | 2013-06-11 23:13:14 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-06-17 17:56:18 +0000 |
commit | fd33a9b60d50e34a1b72a52f22d07da89f5bd3fc (patch) | |
tree | 2e708447b11dc1bce82ab065cc3e99fe7d53e0e0 /sw | |
parent | Rename Blue nine to Blue 11 (diff) | |
download | core-fd33a9b60d50e34a1b72a52f22d07da89f5bd3fc.tar.gz core-fd33a9b60d50e34a1b72a52f22d07da89f5bd3fc.zip |
fdo#55315 Added simple Trie lookup tree for autocomplete words storage
Added simple Trie lookup tree which is more tailored to what is needed
in autocomplete implementation, but still has the speed of the
LatinLookupTree that has been used till now. As the implementation
is much simpler it should be more managable and easier fixable.
For now two actions: insert (word) and findSuggestions are supported.
Acttion findSuggestion returns all words in a list for a searched
sub-word, it also fixes fdo#62945.
Change-Id: I63b69c30d28b4e1c465c2122ebc537f7f75a033a
Reviewed-on: https://gerrit.libreoffice.org/4237
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/acmplwrd.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/acmplwrd.cxx | 18 |
2 files changed, 12 insertions, 10 deletions
diff --git a/sw/inc/acmplwrd.hxx b/sw/inc/acmplwrd.hxx index 7b2f40bea571..7be3b3ffea33 100644 --- a/sw/inc/acmplwrd.hxx +++ b/sw/inc/acmplwrd.hxx @@ -23,7 +23,7 @@ #include <deque> #include <editeng/swafopt.hxx> -#include <editeng/LatinLookupTree.hxx> +#include <editeng/Trie.hxx> class SwDoc; class SwAutoCompleteWord_Impl; @@ -38,7 +38,7 @@ class SwAutoCompleteWord /// contains extended strings carrying source information editeng::SortedAutoCompleteStrings m_WordList; - LookupTree* m_LookupTree; + editeng::Trie m_LookupTree; SwAutoCompleteStringPtrDeque aLRULst; SwAutoCompleteWord_Impl* pImpl; diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx index 2c865b4590e2..9ec7606a1559 100644 --- a/sw/source/core/doc/acmplwrd.cxx +++ b/sw/source/core/doc/acmplwrd.cxx @@ -221,13 +221,11 @@ SwAutoCompleteWord::SwAutoCompleteWord( sal_uInt16 nWords, sal_uInt16 nMWrdLen ) nMinWrdLen( nMWrdLen ), bLockWordLst( sal_False ) { - m_LookupTree = new LatinLookupTree(OUString("default")); } SwAutoCompleteWord::~SwAutoCompleteWord() { m_WordList.DeleteAndDestroyAll(); // so the assertion below works - delete m_LookupTree; delete pImpl; #if OSL_DEBUG_LEVEL > 0 sal_uLong nStrings = SwAutoCompleteString::GetElementCount(); @@ -265,7 +263,7 @@ bool SwAutoCompleteWord::InsertWord( const String& rWord, SwDoc& rDoc ) std::pair<editeng::SortedAutoCompleteStrings::const_iterator, bool> aInsPair = m_WordList.insert(pNew); - m_LookupTree->insert( OUString(aNewWord).copy(0, nWrdLen) ); + m_LookupTree.insert( OUString(aNewWord).copy(0, nWrdLen) ); if (aInsPair.second) { @@ -355,15 +353,19 @@ bool SwAutoCompleteWord::GetWordsMatching(String aMatch, std::vector<String>& aW { OUString aStringRoot = OUString( aMatch ); - m_LookupTree->gotoNode( aStringRoot ); - OUString aAutocompleteWord = m_LookupTree->suggestAutoCompletion(); - if (aAutocompleteWord.isEmpty()) + std::vector<OUString> suggestions; + m_LookupTree.findSuggestions(aStringRoot, suggestions); + + if (suggestions.empty()) { return false; } - OUString aCompleteWord = aStringRoot + aAutocompleteWord; - aWords.push_back( String(aCompleteWord) ); + for (size_t i = 0; i < suggestions.size(); i++) + { + aWords.push_back( String(suggestions[i]) ); + } + return true; } |