summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorTomaž Vajngerl <quikee@gmail.com>2013-06-11 23:13:14 +0200
committerMichael Stahl <mstahl@redhat.com>2013-06-17 21:26:27 +0200
commit033d888b8afae92eb85c7d95bf677d4b7b6e1da0 (patch)
tree41bc617cd02ca5d920d59ca2cb8ff6ee63442dee /sw/source/core
parentf6c8a7f90154ea7251bf7aa8eb6f2db14252060a (diff)
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> (cherry picked from commit fd33a9b60d50e34a1b72a52f22d07da89f5bd3fc) Signed-off-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/doc/acmplwrd.cxx18
1 files changed, 10 insertions, 8 deletions
diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx
index d59d84fb2494..1c0aca404186 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;
}