diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-04-23 15:27:47 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-04-23 15:47:46 +0200 |
commit | d92932744fdbaa78cec8dd8b991d5f442f6eef4b (patch) | |
tree | 87167e9ae86ad02a94015d59a335cccfc7b8c588 /sw/source/ui | |
parent | fe45c9ef10442d0991abd7a45d0e7f2d7c1338e1 (diff) |
fdo#62643 sw: fix autocomplate wrt. adding to a partially finished word
This partially reverts commits 1eee77f2c2b4fa5f693708218c74a8f3909649a6
and 51f9e894f46e718200a14bcd61e9e44c64bc5396.
Change-Id: Ie6a1202e139a0eb30cac482a2bb528ef70c7797f
Diffstat (limited to 'sw/source/ui')
-rw-r--r-- | sw/source/ui/docvw/edtwin.cxx | 125 |
1 files changed, 12 insertions, 113 deletions
diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 1797b1ae5ea5..3ec057d993f8 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 ); } |