[Libreoffice-commits] core.git: sw/inc sw/source

Miklos Vajna vmiklos at suse.cz
Tue Apr 23 06:48:07 PDT 2013


 sw/inc/acmplwrd.hxx             |   17 -----
 sw/source/core/doc/acmplwrd.cxx |   36 -----------
 sw/source/ui/docvw/edtwin.cxx   |  125 +++-------------------------------------
 3 files changed, 16 insertions(+), 162 deletions(-)

New commits:
commit d92932744fdbaa78cec8dd8b991d5f442f6eef4b
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Tue Apr 23 15:27:47 2013 +0200

    fdo#62643 sw: fix autocomplate wrt. adding to a partially finished word
    
    This partially reverts commits 1eee77f2c2b4fa5f693708218c74a8f3909649a6
    and 51f9e894f46e718200a14bcd61e9e44c64bc5396.
    
    Change-Id: Ie6a1202e139a0eb30cac482a2bb528ef70c7797f

diff --git a/sw/inc/acmplwrd.hxx b/sw/inc/acmplwrd.hxx
index 52a3777..7b2f40b 100644
--- a/sw/inc/acmplwrd.hxx
+++ b/sw/inc/acmplwrd.hxx
@@ -68,21 +68,8 @@ public:
 
     void CheckChangedList(const editeng::SortedAutoCompleteStrings& rNewLst);
 
-    // Resets the current position within the tree to its root node.
-    void returnToRoot();
-
-    // Advances to a given node within the AutoComplete tree.
-    void gotoNode(OUString sNode);
-
-    // Advances from the current position towards the node keyed with cKey.
-    void advance(const sal_Unicode cKey);
-
-    // Goes back one char within the tree, except if the current node is already the root node.
-    void goBack();
-
-    // Returns all words matching a given prefix aMatch. If bIgnoreCurrentPos is set, the current
-    // position within the tree is ignored and replaced by aMatch.
-    bool GetWordsMatching(String aMatch, std::vector<String>& aWords, bool bIgnoreCurrentPos) const;
+    // Returns all words matching a given prefix aMatch.
+    bool GetWordsMatching(String aMatch, std::vector<String>& aWords) const;
 };
 
 
diff --git a/sw/source/core/doc/acmplwrd.cxx b/sw/source/core/doc/acmplwrd.cxx
index 0e8c2ae..4853ffc 100644
--- a/sw/source/core/doc/acmplwrd.cxx
+++ b/sw/source/core/doc/acmplwrd.cxx
@@ -346,48 +346,16 @@ void SwAutoCompleteWord::SetMinWordLen( sal_uInt16 n )
     nMinWrdLen = n;
 }
 
-/// Reset the current position within the tree to its root node.
-void SwAutoCompleteWord::returnToRoot()
-{
-    m_LookupTree->returnToRoot();
-}
-
-/// Advance to a given node within the AutoComplete tree.
-void SwAutoCompleteWord::gotoNode(OUString sNode)
-{
-    m_LookupTree->gotoNode( sNode );
-}
-
-/// Advance from the current position towards the node keyed with cKey.
-void SwAutoCompleteWord::advance(const sal_Unicode cKey)
-{
-    m_LookupTree->advance( cKey );
-}
-
-/// Go back one char within the tree, except if the current node is already the root node.
-void SwAutoCompleteWord::goBack()
-{
-    m_LookupTree->goBack();
-}
-
 /** Return all words matching a given prefix
  *
  *  @param aMatch the prefix to search for
  *  @param aWords the words to search in
- *  @param bIgnoreCurrentPos if set, the current position within the tree is ignored and replaced by aMatch
  */
-bool SwAutoCompleteWord::GetWordsMatching(String aMatch, std::vector<String>& aWords, bool bIgnoreCurrentPos) const
+bool SwAutoCompleteWord::GetWordsMatching(String aMatch, std::vector<String>& aWords) const
 {
     OUString aStringRoot = OUString( aMatch );
 
-    // The lookup tree already contains the information about the root keyword in most cases. Only if we don't trust that
-    // information (e.g. if we need some autocompletion for a place other than the main writing area), the location within
-    // the tree needs to be refreshed.
-    if (bIgnoreCurrentPos)
-    {
-        m_LookupTree->gotoNode( aStringRoot );
-    }
-
+    m_LookupTree->gotoNode( aStringRoot );
     OUString aAutocompleteWord = m_LookupTree->suggestAutoCompletion();
     if (aAutocompleteWord.isEmpty())
     {
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx
index 1797b1a..3ec057d 100644
--- a/sw/source/ui/docvw/edtwin.cxx
+++ b/sw/source/ui/docvw/edtwin.cxx
@@ -277,7 +277,7 @@ struct QuickHelpData
     }
 
     // Fills internal structures with hopefully helpful information.
-    void FillStrArr( SwWrtShell& rSh, const String& rWord, bool bIgnoreCurrentPos );
+    void FillStrArr( SwWrtShell& rSh, const String& rWord );
     void SortAndFilter();
 };
 
@@ -1488,19 +1488,6 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt)
     bool bStopKeyInputTimer = true;
     String sFmlEntry;
 
-    enum SW_AutoCompleteAction { ACA_NoOp,            // No maintenance operation required for AutoComplete tree
-                                 ACA_ReturnToRoot,    // Input of a char marking the end of a word, like '.', ' ', etc.
-                                 ACA_SingleCharInput,
-                                 ACA_SingleBackspace,
-                                 ACA_Refresh };       // Refresh AutoComplete information completely.
-
-    // Do refresh by default to gracefully handle all unimplemented special cases.
-    SW_AutoCompleteAction eAutoCompleteAction = ACA_Refresh;
-    // TODO: Make sure eAutoCompleteAction is set to something other than ACA_Refresh to increase performance.
-
-    // Stores input char in case ACA_SingleCharInput is used. Defaults to aCh to avoid compiler warning.
-    sal_Unicode aSingleCharInput = aCh;
-
     enum SW_KeyState { KS_Start,
                        KS_CheckKey, KS_InsChar, KS_InsTab,
                        KS_NoNum, KS_NumOff, KS_NumOrNoNum, KS_NumDown, KS_NumUp,
@@ -1683,10 +1670,6 @@ KEYINPUT_CHECKTABLE:
                     break;
 
                 case KEY_LEFT:
-                {
-                    eAutoCompleteAction = ACA_ReturnToRoot;
-                }
-                // No break;
                 case KEY_LEFT | KEY_MOD1:
                 {
                     bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
@@ -1709,10 +1692,6 @@ KEYINPUT_CHECKTABLE:
                 }
                     goto KEYINPUT_CHECKTABLE_INSDEL;
                 case KEY_UP:
-                {
-                    eAutoCompleteAction = ACA_ReturnToRoot;
-                }
-                // No break;
                 case KEY_UP | KEY_MOD1:
                 {
                     bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
@@ -1729,10 +1708,6 @@ KEYINPUT_CHECKTABLE:
                 }
                     goto KEYINPUT_CHECKTABLE_INSDEL;
                 case KEY_DOWN:
-                {
-                    eAutoCompleteAction = ACA_ReturnToRoot;
-                }
-                // No break;
                 case KEY_DOWN | KEY_MOD1:
                 {
                     bool bMod1 = 0 != (rKeyCode.GetModifier() & KEY_MOD1);
@@ -1780,7 +1755,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                     {
                         if (rSh.IsInFrontOfLabel() && rSh.NumOrNoNum(sal_False))
                             eKeyState = KS_NumOrNoNum;
-                        eAutoCompleteAction = ACA_NoOp;
                     }
                     else
                     {
@@ -1797,7 +1771,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         m_bTblIsInsMode = sal_False;
                         m_aKeyInputTimer.Start();
                         bStopKeyInputTimer = false;
-                        eAutoCompleteAction = ACA_NoOp;
                     }
                     break;
                 case KEY_INSERT | KEY_MOD2:
@@ -1808,7 +1781,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         m_bTblIsInsMode = sal_True;
                         m_aKeyInputTimer.Start();
                         bStopKeyInputTimer = false;
-                        eAutoCompleteAction = ACA_NoOp;
                     }
                     break;
 
@@ -1847,7 +1819,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         else
                             eNextKeyState = eKeyState, eKeyState = KS_CheckAutoCorrect;
                     }
-                    eAutoCompleteAction = ACA_ReturnToRoot;
                 }
                 break;
                 case KEY_RETURN | KEY_MOD2:     // ALT-Return
@@ -1856,7 +1827,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         eKeyState = KS_NoNum;
                     else if( rSh.CanSpecialInsert() )
                         eKeyState = KS_SpecialInsert;
-                    eAutoCompleteAction = ACA_ReturnToRoot;
                 }
                 break;
                 case KEY_BACKSPACE:
@@ -1881,11 +1851,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                             bDone = rSh.TryRemoveIndent();
                         }
 
-                        if ( bOnlyBackspaceKey )
-                        {
-                            eAutoCompleteAction = ACA_SingleBackspace;
-                        }
-
                         if (bDone)
                             eKeyState = KS_End;
                         else
@@ -1964,7 +1929,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         nDir = MOVE_RIGHT_BIG;
                         eTblChgMode = nsTblChgWidthHeightType::WH_FLAG_INSDEL | nsTblChgWidthHeightType::WH_COL_RIGHT;
                         nTblChgSize = pModOpt->GetTblVInsert();
-                        eAutoCompleteAction = ACA_ReturnToRoot;
                         goto KEYINPUT_CHECKTABLE_INSDEL;
                     }
                 case KEY_TAB:
@@ -2080,7 +2044,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         {
                             eKeyState = KS_InsTab;
                         }
-                        eAutoCompleteAction = ACA_NoOp;
                     }
                     break;
 
@@ -2100,7 +2063,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         {
                             eKeyState = KS_EnterDrawHandleMode;
                         }
-                        eAutoCompleteAction = ACA_NoOp;
                     }
                     break;
                     case KEY_F2 :
@@ -2111,7 +2073,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                             eKeyState = KS_GoIntoFly;
                         else if((nSelectionType & nsSelectionType::SEL_DRW))
                             eKeyState = KS_GoIntoDrawing;
-                        eAutoCompleteAction = ACA_NoOp;
                     }
                     break;
                 }
@@ -2161,7 +2122,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                     }
                     break;
                 }
-                eAutoCompleteAction = ACA_NoOp;
             }
             break;
 
@@ -2181,7 +2141,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         FlushInBuffer();
                         break;
                 }
-                eAutoCompleteAction = ACA_NoOp;
             }
             break;
 
@@ -2243,25 +2202,12 @@ KEYINPUT_CHECKTABLE_INSDEL:
                         Window::KeyInput( aKeyEvent );
                     }
                 }
-                if( bNormalChar )
-                {
-                    if ( aCh == ' ' )
-                    {
-                        eAutoCompleteAction = ACA_ReturnToRoot;
-                    }
-                    else
-                    {
-                        eAutoCompleteAction = ACA_SingleCharInput;
-                        aSingleCharInput = aCh;
-                    }
-                }
             }
             break;
         case KS_LaunchOLEObject:
         {
             rSh.LaunchOLEObj();
             eKeyState = KS_End;
-            eAutoCompleteAction = ACA_NoOp;
         }
         break;
         case KS_GoIntoFly:
@@ -2271,7 +2217,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
             m_rView.AttrChangedNotify(&rSh);
             rSh.MoveSection( fnSectionCurr, fnSectionEnd );
             eKeyState = KS_End;
-            eAutoCompleteAction = ACA_NoOp;
         }
         break;
         case KS_GoIntoDrawing:
@@ -2284,7 +2229,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                     ((SwDrawTextShell*)m_rView.GetCurShell())->Init();
             }
             eKeyState = KS_End;
-            eAutoCompleteAction = ACA_NoOp;
         }
         break;
         case KS_EnterDrawHandleMode:
@@ -2294,7 +2238,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
 
             ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
             eKeyState = KS_End;
-            eAutoCompleteAction = ACA_NoOp;
         }
         break;
         case KS_InsTab:
@@ -2306,7 +2249,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                 break;
             }
             aCh = '\t';
-            eAutoCompleteAction = ACA_ReturnToRoot;
             // no break!
         case KS_InsChar:
             if (rSh.GetChar(sal_False)==CH_TXT_ATR_FORMELEMENT)
@@ -2411,8 +2353,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                 rSh.AutoCorrect( *pACorr, static_cast< sal_Unicode >('\0') );
             }
             eKeyState = eNextKeyState;
-            if ( eAutoCompleteAction == ACA_Refresh )
-                eAutoCompleteAction = ACA_NoOp;
         }
         break;
 
@@ -2534,7 +2474,6 @@ KEYINPUT_CHECKTABLE_INSDEL:
                             pACorr->GetSwFlags().bAutoCmpltAppendBlanc;
                 }
                 rSh.EndUndo( UNDO_END );
-                eAutoCompleteAction = ACA_ReturnToRoot;
             }
             break;
 
@@ -2624,66 +2563,26 @@ KEYINPUT_CHECKTABLE_INSDEL:
         m_bTblInsDelMode = sal_False;
     }
 
-    bool bInsertBufferedChars = bFlushBuffer && m_aInBuffer.Len();
-    bool bAutoCompleteEnabled = pACfg && pACorr && ( pACfg->IsAutoTextTip() || pACorr->GetSwFlags().bAutoCompleteWords );
-    bool bGotWord = false;
-    String sPrefix;
-
     // in case the buffered characters are inserted
-    if( bInsertBufferedChars )
+    if( bFlushBuffer && m_aInBuffer.Len() )
     {
         // bFlushCharBuffer was not resetted here
         // why not?
         bool bSave = bFlushCharBuffer;
         FlushInBuffer();
         bFlushCharBuffer = bSave;
-    }
 
-    // maintain AutoComplete tree
-    if( bAutoCompleteEnabled )
-    {
-        // avoid unnecessary calls to GetPrevAutoCorrWord
-        if( (bInsertBufferedChars && bNormalChar) || eAutoCompleteAction == ACA_Refresh )
-        {
-            bGotWord = rSh.GetPrevAutoCorrWord( *pACorr, sPrefix );
-        }
-
-        SwAutoCompleteWord& rACList = rSh.GetAutoCompleteWords();
-
-        switch( eAutoCompleteAction )
+        // maybe show Tip-Help
+        String sWord;
+        if( bNormalChar && pACfg && pACorr &&
+            ( pACfg->IsAutoTextTip() ||
+              pACorr->GetSwFlags().bAutoCompleteWords ) &&
+            rSh.GetPrevAutoCorrWord( *pACorr, sWord ) )
         {
-            case ACA_NoOp:
-                // do nothing
-            break;
-
-            case ACA_ReturnToRoot:
-                rACList.returnToRoot();
-            break;
-
-            case ACA_SingleCharInput:
-                rACList.advance( aSingleCharInput );
-            break;
-
-            case ACA_SingleBackspace:
-                rACList.goBack();
-            break;
-
-            case ACA_Refresh:
-            {
-                if( sPrefix.Len() > 0 )
-                    rACList.gotoNode( sPrefix );
-                else
-                    rACList.returnToRoot();
-            }
-            break;
+            ShowAutoTextCorrectQuickHelp(sWord, pACfg, pACorr);
         }
     }
 
-    if( bInsertBufferedChars && bNormalChar && bAutoCompleteEnabled && bGotWord )
-    {
-        ShowAutoTextCorrectQuickHelp( sPrefix, pACfg, pACorr );
-    }
-
     // get the word count dialog to update itself
     SwWordCountWrapper *pWrdCnt = (SwWordCountWrapper*)GetView().GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId());
     if( pWrdCnt )
@@ -5681,7 +5580,7 @@ void QuickHelpData::Stop( SwWrtShell& rSh )
     ClearCntnt();
 }
 
-void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord, bool bIgnoreCurrentPos )
+void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord )
 {
     enum Capitalization { CASE_LOWER, CASE_UPPER, CASE_SENTENCE, CASE_OTHER };
 
@@ -5749,7 +5648,7 @@ void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord, bool bIgno
     const SwAutoCompleteWord& rACList = rSh.GetAutoCompleteWords();
     std::vector<String> strings;
 
-    if ( rACList.GetWordsMatching( rWord, strings, bIgnoreCurrentPos ) )
+    if ( rACList.GetWordsMatching( rWord, strings ) )
     {
         for (unsigned int i= 0; i<strings.size(); i++)
         {
@@ -5827,7 +5726,7 @@ void SwEditWin::ShowAutoTextCorrectQuickHelp(
                     pACorr->GetSwFlags().bAutoCmpltShowAsTip;
 
         // Get the necessary data to show help text.
-        m_pQuickHlpData->FillStrArr( rSh, rWord, bFromIME );
+        m_pQuickHlpData->FillStrArr( rSh, rWord );
     }
 
 


More information about the Libreoffice-commits mailing list