tdf#119695 only add word to autocomplete suggestions when the cursor leaves it

so that incomplete words are not added as autocomplete candidates even
if they form a legal word. This is similar to what we do for marking
words is misspelt

Change-Id: Ib6b209b68bbcf51fa24ea5c4d995579acf682e52
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118974
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 8913fbd..c98946a4 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1357,7 +1357,11 @@ SwRect SwTextFrame::AutoSpell_(SwTextNode & rNode, sal_Int32 nActPos)
                }
                else if( bAddAutoCmpl && rACW.GetMinWordLen() <= rWord.getLength() )
                {
                    rACW.InsertWord( rWord, rDoc );
                    // tdf#119695 only add the word if the cursor position is outside the word
                    // so that the incomplete words are not added as autocomplete candidates
                    bool bCursorOutsideWord = nActPos > nBegin + nLen || nActPos < nBegin;
                    if (bCursorOutsideWord)
                        rACW.InsertWord(rWord, rDoc);
                }
            }
        }