FWL_ERR CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { CXFA_FFField::OnProcessEvent(pEvent); FX_DWORD dwEventID = pEvent->GetClassID(); switch (dwEventID) { case FWL_EVTHASH_EDT_TextChanged: { CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent; CFX_WideString wsChange; OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); break; } case FWL_EVTHASH_EDT_AddDoRecord: { OnAddDoRecord(m_pNormalWidget->GetWidget()); break; } case FWL_EVTHASH_EDT_TextFull: { OnTextFull(m_pNormalWidget->GetWidget()); break; } case FWL_EVTHASH_EDT_CheckWord: { CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent; event->bCheckWord = CheckWord(event->bsWord); break; } case FWL_EVTHASH_EDT_GetSuggestWords: { CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent; event->bSuggestWords = GetSuggestWords(event->bsWord, event->bsArraySuggestWords); break; } default: {} } return m_pOldDelegate->OnProcessEvent(pEvent); }
NS_IMETHODIMP nsEditorSpellCheck::CheckCurrentWordNoSuggest(const PRUnichar *aSuggestedWord, PRBool *aIsMisspelled) { NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED); return mSpellChecker->CheckWord(nsDependentString(aSuggestedWord), aIsMisspelled, nsnull); }
int main(int argc, char **argv) { char randword[DEF_MAX_WORD_LENGTH + 1]; int randlen; short i, stop = 0; /* Parse the command line arguments */ parseArgs(argc, argv); /* Seed the random number generator */ srand(time(NULL)); /* If something goes wrong in init, it'll take care of itself */ InitProgram(); /* Register exit function */ signal(SIGINT, SigHandler); atexit(ExitProgram); /* Start generate strings */ while (!stop) { randlen = rand() % (maxWordLength - minWordLength + 1) + minWordLength; for (i = 0; i < randlen; i++) randword[i] = (unsigned char)(rand() % 26 + 97); randword[randlen] = '\0'; totalcount++; if (CheckWord(randword, randlen)) { numfound++; printf("%s", randword); if (verbose) printf(" *"); printf("%s", ENDL); if (stopAfterLength && randlen == xLength) stop = 1; } else if (verbose) printf("%s%s", randword, ENDL); if (stopAfterWord && strcmp(xWord, randword) == 0) stop = 1; if (stopAfterHits && numfound == xHits) stop = 1; } return 0; }
main(){ try{ while(cin >> input_word) if(!CheckWord()){ Output(false); return 0; } Output(stack.is_empty()); } catch(...){ Output(false); } return 0; }
int Commit() { if( wordbuffer[0] ) { // we only check 2+ letter words if( strlen( wordbuffer ) > 1 ) { bool valid = CheckWord( wordbuffer ); if( !valid ) { logf( 2, RED "INVALID WORD [%s]\n", wordbuffer ); return false; } } } wordbuffer[0] = 0; l = 0; return true; }
NS_IMETHODIMP mozSpellChecker::NextMisspelledWord(nsAString &aWord, nsTArray<nsString> *aSuggestions) { if(!aSuggestions||!mConverter) return NS_ERROR_NULL_POINTER; int32_t selOffset; int32_t begin,end; nsresult result; result = SetupDoc(&selOffset); bool isMisspelled,done; if (NS_FAILED(result)) return result; while( NS_SUCCEEDED(mTsDoc->IsDone(&done)) && !done ) { nsString str; result = mTsDoc->GetCurrentTextBlock(&str); if (NS_FAILED(result)) return result; do{ result = mConverter->FindNextWord(str.get(),str.Length(),selOffset,&begin,&end); if(NS_SUCCEEDED(result)&&(begin != -1)){ const nsAString &currWord = Substring(str, begin, end - begin); result = CheckWord(currWord, &isMisspelled, aSuggestions); if(isMisspelled){ aWord = currWord; mTsDoc->SetSelection(begin, end-begin); // After ScrollSelectionIntoView(), the pending notifications might // be flushed and PresShell/PresContext/Frames may be dead. // See bug 418470. mTsDoc->ScrollSelectionIntoView(); return NS_OK; } } selOffset = end; }while(end != -1); mTsDoc->NextBlock(); selOffset=0; } return NS_OK; }
NS_IMETHODIMP mozSpellChecker::NextMisspelledWord(nsAString &aWord, nsStringArray *aSuggestions) { if(!aSuggestions||!mConverter) return NS_ERROR_NULL_POINTER; PRUint32 selOffset; PRInt32 begin,end; nsresult result; result = SetupDoc(&selOffset); PRBool isMisspelled,done; if (NS_FAILED(result)) return result; while( NS_SUCCEEDED(mTsDoc->IsDone(&done)) && !done ) { nsString str; result = mTsDoc->GetCurrentTextBlock(&str); if (NS_FAILED(result)) return result; do{ result = mConverter->FindNextWord(str.get(),str.Length(),selOffset,&begin,&end); if(NS_SUCCEEDED(result)&&(begin != -1)){ const nsAString &currWord = Substring(str, begin, end - begin); result = CheckWord(currWord, &isMisspelled, aSuggestions); if(isMisspelled){ aWord = currWord; mTsDoc->SetSelection(begin, end-begin); mTsDoc->ScrollSelectionIntoView(); return NS_OK; } } selOffset = end; }while(end != -1); mTsDoc->NextBlock(); selOffset=0; } return NS_OK; }
void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { CXFA_FFField::OnProcessEvent(pEvent); switch (pEvent->GetClassID()) { case CFWL_EventType::TextChanged: { CFWL_EvtTextChanged* event = static_cast<CFWL_EvtTextChanged*>(pEvent); CFX_WideString wsChange; OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); break; } case CFWL_EventType::TextFull: { OnTextFull(m_pNormalWidget->GetWidget()); break; } case CFWL_EventType::CheckWord: { CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); CFWL_EvtCheckWord* event = static_cast<CFWL_EvtCheckWord*>(pEvent); event->bCheckWord = CheckWord(event->bsWord.AsStringC()); break; } default: break; } m_pOldDelegate->OnProcessEvent(pEvent); }
/*---------------------------------------------------------------------- ApplyCommand traite l'action de correction demandee. ----------------------------------------------------------------------*/ static void ApplyCommand (int val) { PtrDocument document; CHARSET defaultCharset; unsigned char *word; ThotBool change; if (ChkrRange == NULL) /* Le correcteur n'est pas lance */ return; /* Teste l'etat de la nouvelle selection */ document = ChkrRange->SDocument; change = CheckChangeSelection (); if (document != ChkrRange->SDocument || val == 0) /* ABANDON de la corrrection */ RemoveSpellForm (); else { change = TRUE; /* On passe a priori au mot suivant */ switch (val) { case 1: /* Passer sans maj du dictionnaire */ break; case 2: /* Passer apres maj du dictionnaire */ /* mettre BadWord dans le dictionnaire */ if (ChkrElement != NULL) { /* Sauf au 1er lancement */ defaultCharset = TtaGetDefaultCharset (); if (CorrectWord[0] != EOS && strcmp (CorrectWord, ChkrCorrection[1])) { /* ajouter le mot corrige dans le dictionaire */ if (defaultCharset == UTF_8) word = TtaConvertMbsToByte ((unsigned char *)CorrectWord, ISO_8859_1); else word = (unsigned char *)CorrectWord; if (!CheckWord (word, ChkrLanguage, ChkrFileDict)) AddWord (word, &ChkrFileDict); } else { /* ajouter le mot courant dans le dictionnaire */ word = (unsigned char *)ChkrErrWord; if (!CheckWord (word, ChkrLanguage, ChkrFileDict)) AddWord (word, &ChkrFileDict); } } break; case 3: /* ToReplace */ if (ToReplace) /* CorrectWord est rempli */ { /* et ce n'est pas 1er lancement */ if (ChkrElement && BadWord[0] != EOS && !document->DocReadOnly && !ElementIsReadOnly(ChkrElement)) WordReplace ((unsigned char*)BadWord, (unsigned char*)CorrectWord); ToReplace = FALSE; } break; case 4: /* ToReplace et maj dictionnaire */ if (ToReplace) /* CorrectWord est rempli */ { /* et ce n'est pas 1er lancement */ if (ChkrElement && BadWord[0] != EOS && !document->DocReadOnly && !ElementIsReadOnly(ChkrElement)) { WordReplace ((unsigned char*)BadWord, (unsigned char*)CorrectWord); /* mettre CorrectWord dans le dictionnaire */ defaultCharset = TtaGetDefaultCharset (); if (defaultCharset == UTF_8) word = TtaConvertMbsToByte ((unsigned char *)CorrectWord, ISO_8859_1); else word = (unsigned char *)CorrectWord; if (!CheckWord (word, ChkrLanguage, ChkrFileDict)) /* mettre ce nouveau mot dans le dictionnaire */ AddWord (word, &ChkrFileDict); if (defaultCharset == UTF_8) TtaFreeMemory (word); } ToReplace = FALSE; } break; } if (change) /* Lancement de la recherche d'erreur suivante */ StartSpellChecker (); } }
void Search::SearchLoop() { while(true) { if (!DownLevel()) { break; } while (SI.GetState()==SI.Ok && _srchState==Ok) { if (SI.IsDots()) { SI.NextItem(); if (SI.IsDots()) { SI.NextItem(); }; }else if (SI.IsReparsePoint()) { if (!_fsValid && CheckWord()) { std::wstring w(SI.GetPath()); w+=SI.GetName(); OutputString(w.c_str()); if(_srchState==Ok) { _directoriesFound++; }; } if (_srchState==Ok) { _directoryCount++; SI.NextItem(); } }else if (SI.IsDirectory()) { if (!_fsValid && CheckWord()) { std::wstring w(SI.GetPath()); w+=SI.GetName(); OutputString(w.c_str()); if(_srchState==Ok) { _directoriesFound++; }; }; if(_srchState==Ok) { _directoryCount++; OpenDir(); } }else { if (CheckWord() && CheckFileSize()) { std::wstring w(SI.GetPath()); w+=SI.GetName(); OutputString(w.c_str()); if (_srchState==Ok) { _filesFound++; } }; if(_srchState==Ok) { SI.NextItem(); _fileCount++;//Seems like it counts one too much, but the FindFirstFile isn't counted, so it evens out. //This is for the windows/winsxs folder, which often stalls the whole program if ((_fileCount%100==0)&&(clock()-_cycleTimer)>=150 && _stable) { SetTimer(_h,1,1,0); return; } } }; }; }; }