From 02899659835bd6352f42a90a344b1de896f6a6a8 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Fri, 12 Dec 2014 18:28:12 +0000 Subject: SpellChecker: changed warning lavel to w4 git-svn-id: http://svn.miranda-ng.org/main/trunk@11354 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SpellChecker/spellchecker_12.vcxproj | 8 +- plugins/SpellChecker/src/ardialog.cpp | 80 +++---- plugins/SpellChecker/src/autoreplace.cpp | 4 +- plugins/SpellChecker/src/commons.h | 2 +- plugins/SpellChecker/src/dictionary.cpp | 7 +- plugins/SpellChecker/src/options.cpp | 298 +++++++++++++-------------- plugins/SpellChecker/src/spellchecker.cpp | 12 +- plugins/SpellChecker/src/utils.cpp | 16 +- 8 files changed, 210 insertions(+), 217 deletions(-) diff --git a/plugins/SpellChecker/spellchecker_12.vcxproj b/plugins/SpellChecker/spellchecker_12.vcxproj index 3958dd3755..8e0aa69b69 100644 --- a/plugins/SpellChecker/spellchecker_12.vcxproj +++ b/plugins/SpellChecker/spellchecker_12.vcxproj @@ -81,7 +81,7 @@ NDEBUG;_WINDOWS;_USRDLL;HUNSPELL_STATIC;%(PreprocessorDefinitions) true true - Level3 + Level4 Size false Use @@ -110,7 +110,7 @@ NDEBUG;_WINDOWS;_USRDLL;HUNSPELL_STATIC;%(PreprocessorDefinitions) true true - Level3 + Level4 Size false Use @@ -137,7 +137,7 @@ ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) _DEBUG;_WINDOWS;_USRDLL;HUNSPELL_STATIC;%(PreprocessorDefinitions) MultiThreadedDebugDLL - Level3 + Level4 EditAndContinue EnableFastChecks Use @@ -163,7 +163,7 @@ ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) _DEBUG;_WINDOWS;_USRDLL;HUNSPELL_STATIC;%(PreprocessorDefinitions) MultiThreadedDebugDLL - Level3 + Level4 EnableFastChecks Use commons.h diff --git a/plugins/SpellChecker/src/ardialog.cpp b/plugins/SpellChecker/src/ardialog.cpp index 1bf94a01f6..720f64a27b 100644 --- a/plugins/SpellChecker/src/ardialog.cpp +++ b/plugins/SpellChecker/src/ardialog.cpp @@ -1,4 +1,4 @@ -/* +/* Copyright (C) 2006-2010 Ricardo Pescuma Domenecci This is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this file; see the file license.txt. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. +Boston, MA 02111-1307, USA. */ #include "commons.h" @@ -36,7 +36,7 @@ struct Data void *param; }; -BOOL ShowAutoReplaceDialog(HWND parent, BOOL modal, +BOOL ShowAutoReplaceDialog(HWND parent, BOOL modal, Dictionary *dict, const TCHAR *find, const TCHAR *replace, BOOL useVariables, BOOL findReadOnly, AutoReplaceDialogCallback callback, void *param) { @@ -68,9 +68,9 @@ BOOL ShowAutoReplaceDialog(HWND parent, BOOL modal, static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - Data *data = (Data *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + Data *data = (Data *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - switch(msg) { + switch (msg) { case WM_CHAR: if (wParam == VK_BACK) break; @@ -79,7 +79,7 @@ static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP if (GetKeyState(VK_CONTROL) & 0x8000) // CTRL key break; { - TCHAR c = (TCHAR) wParam; + TCHAR c = (TCHAR)wParam; if (!data->dict->autoReplace->isWordChar(c)) return 1; @@ -93,7 +93,7 @@ static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP LRESULT ret = mir_callNextSubclass(hwnd, OnlyCharsEditProc, msg, wParam, lParam); - switch(msg) { + switch (msg) { case EM_PASTESPECIAL: case WM_PASTE: TCHAR text[256]; @@ -197,8 +197,8 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa rc_new.right = rc_old.right; SetWindowPos(GetDlgItem(hwndDlg, IDC_NEW), NULL, 0, 0, - rc_new.right - rc_new.left, rc_new.bottom - rc_new.top, - SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOZORDER); + rc_new.right - rc_new.left, rc_new.bottom - rc_new.top, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOZORDER); } else { variables_skin_helpbutton(hwndDlg, IDC_VAR_HELP); @@ -212,38 +212,38 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa case WM_COMMAND: switch (wParam) { case IDOK: - { - Data *data = (Data *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - TCHAR find[256]; - if (data->findReadOnly) - mir_tstrncpy(find, data->find.c_str(), SIZEOF(find)); - else { - GetDlgItemText(hwndDlg, IDC_OLD, find, SIZEOF(find)); - lstrtrim(find); - } - - TCHAR replace[256]; - GetDlgItemText(hwndDlg, IDC_NEW, replace, SIZEOF(replace)); - lstrtrim(replace); - - if (!data->findReadOnly && find[0] == 0) - MessageBox(hwndDlg, TranslateT("The wrong word can't be empty!"), TranslateT("Wrong Correction"), MB_OK | MB_ICONERROR); - - else if (replace[0] == 0) - MessageBox(hwndDlg, TranslateT("The correction can't be empty!"), TranslateT("Wrong Correction"), MB_OK | MB_ICONERROR); - - else if (_tcscmp(find, replace) == 0) - MessageBox(hwndDlg, TranslateT("The correction can't be equal to the wrong word!"), TranslateT("Wrong Correction"), MB_OK | MB_ICONERROR); - - else { - data->callback(FALSE, data->dict, - find, replace, IsDlgButtonChecked(hwndDlg, IDC_VARIABLES), - data->find.c_str(), data->param); - Close(hwndDlg, 1); - } + { + Data *data = (Data *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + TCHAR find[256]; + if (data->findReadOnly) + mir_tstrncpy(find, data->find.c_str(), SIZEOF(find)); + else { + GetDlgItemText(hwndDlg, IDC_OLD, find, SIZEOF(find)); + lstrtrim(find); } - break; + + TCHAR replace[256]; + GetDlgItemText(hwndDlg, IDC_NEW, replace, SIZEOF(replace)); + lstrtrim(replace); + + if (!data->findReadOnly && find[0] == 0) + MessageBox(hwndDlg, TranslateT("The wrong word can't be empty!"), TranslateT("Wrong Correction"), MB_OK | MB_ICONERROR); + + else if (replace[0] == 0) + MessageBox(hwndDlg, TranslateT("The correction can't be empty!"), TranslateT("Wrong Correction"), MB_OK | MB_ICONERROR); + + else if (_tcscmp(find, replace) == 0) + MessageBox(hwndDlg, TranslateT("The correction can't be equal to the wrong word!"), TranslateT("Wrong Correction"), MB_OK | MB_ICONERROR); + + else { + data->callback(FALSE, data->dict, + find, replace, IsDlgButtonChecked(hwndDlg, IDC_VARIABLES), + data->find.c_str(), data->param); + Close(hwndDlg, 1); + } + } + break; case IDCANCEL: Close(hwndDlg, 0); diff --git a/plugins/SpellChecker/src/autoreplace.cpp b/plugins/SpellChecker/src/autoreplace.cpp index a3a8425844..c22a1fe5aa 100644 --- a/plugins/SpellChecker/src/autoreplace.cpp +++ b/plugins/SpellChecker/src/autoreplace.cpp @@ -14,7 +14,7 @@ Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this file; see the file license.txt. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. +Boston, MA 02111-1307, USA. */ #include "commons.h" @@ -52,7 +52,7 @@ void AutoReplaceMap::loadAutoReplaceMap() tmp[pos] = '\0'; // Get from - BOOL useVars; + BOOL useVars = false; char *p; if ((p = strstr(tmp, "->")) != NULL) { *p = '\0'; diff --git a/plugins/SpellChecker/src/commons.h b/plugins/SpellChecker/src/commons.h index a0841026e7..4cdc7c00a3 100644 --- a/plugins/SpellChecker/src/commons.h +++ b/plugins/SpellChecker/src/commons.h @@ -142,7 +142,7 @@ struct Dialog vector *wrong_words; }; -BOOL CenterParent(HWND hwnd); +static BOOL CenterParent(HWND hwnd); TCHAR *lstrtrim(TCHAR *str); BOOL lstreq(TCHAR *a, TCHAR *b, size_t len = -1); BOOL IsNumber(TCHAR c); diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp index 44597254e0..64adc2f33a 100644 --- a/plugins/SpellChecker/src/dictionary.cpp +++ b/plugins/SpellChecker/src/dictionary.cpp @@ -14,7 +14,7 @@ Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this file; see the file license.txt. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. +Boston, MA 02111-1307, USA. */ #include "commons.h" @@ -841,7 +841,7 @@ void GetHunspellDictionariesFromFolder(LIST &dicts, TCHAR *path, TCH TCHAR *lang = ffd.cFileName; // Replace - for _ - for (int i = 0; i < mir_tstrlen(lang); i++) + for (size_t i = 0; i < mir_tstrlen(lang); i++) if (lang[i] == _T('-')) lang[i] = _T('_'); @@ -856,8 +856,7 @@ void GetHunspellDictionariesFromFolder(LIST &dicts, TCHAR *path, TCH file[mir_tstrlen(file) - 4] = _T('\0'); dicts.insert(new HunspellDictionary(lang, file, user_path, source)); } - } - while (FindNextFile(hFFD, &ffd)); + } while (FindNextFile(hFFD, &ffd)); FindClose(hFFD); } diff --git a/plugins/SpellChecker/src/options.cpp b/plugins/SpellChecker/src/options.cpp index d1f765edff..9325387e43 100644 --- a/plugins/SpellChecker/src/options.cpp +++ b/plugins/SpellChecker/src/options.cpp @@ -1,4 +1,4 @@ -/* +/* Copyright (C) 2006-2010 Ricardo Pescuma Domenecci This is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this file; see the file license.txt. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. +Boston, MA 02111-1307, USA. */ @@ -27,33 +27,33 @@ Options opts; static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK AutoreplaceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static OptPageControl optionsControls[] = { - { &opts.auto_replace_dict, CONTROL_CHECKBOX, IDC_AUTO_DICT, "AutoReplaceDict", FALSE }, - { &opts.ignore_with_numbers, CONTROL_CHECKBOX, IDC_IGNORE_NUMBERS, "IgnoreWithNumbers", FALSE }, - { &opts.ignore_uppercase, CONTROL_CHECKBOX, IDC_IGNORE_UPPERCASE, "IgnoreUppercase", FALSE }, - { &opts.ask_when_sending_with_error, CONTROL_CHECKBOX, IDC_ASK_ON_ERROR, "AskWhenSendingWithError", FALSE }, - { &opts.underline_type, CONTROL_COMBO, IDC_UNDERLINE_TYPE, "UnderlineType", CFU_UNDERLINEWAVE - CFU_UNDERLINEDOUBLE }, - { &opts.cascade_corrections, CONTROL_CHECKBOX, IDC_CASCADE_CORRECTIONS, "CascadeCorrections", FALSE }, - { &opts.show_all_corrections, CONTROL_CHECKBOX, IDC_SHOW_ALL_CORRECTIONS, "ShowAllCorrections", FALSE }, - { &opts.show_wrong_word, CONTROL_CHECKBOX, IDC_SHOW_WRONG_WORD, "ShowWrongWord", TRUE }, - { &opts.use_flags, CONTROL_CHECKBOX, IDC_USE_FLAGS, "UseFlags", TRUE }, - { &opts.auto_locale, CONTROL_CHECKBOX, IDC_AUTO_LOCALE, "AutoLocale", FALSE }, - { &opts.use_other_apps_dicts, CONTROL_CHECKBOX, IDC_OTHER_PROGS, "UseOtherAppsDicts", TRUE }, - { &opts.handle_underscore, CONTROL_CHECKBOX, IDC_HANDLE_UNDERSCORE, "HandleUnderscore", FALSE }, +static OptPageControl optionsControls[] = { + { &opts.auto_replace_dict, CONTROL_CHECKBOX, IDC_AUTO_DICT, "AutoReplaceDict", FALSE }, + { &opts.ignore_with_numbers, CONTROL_CHECKBOX, IDC_IGNORE_NUMBERS, "IgnoreWithNumbers", FALSE }, + { &opts.ignore_uppercase, CONTROL_CHECKBOX, IDC_IGNORE_UPPERCASE, "IgnoreUppercase", FALSE }, + { &opts.ask_when_sending_with_error, CONTROL_CHECKBOX, IDC_ASK_ON_ERROR, "AskWhenSendingWithError", FALSE }, + { &opts.underline_type, CONTROL_COMBO, IDC_UNDERLINE_TYPE, "UnderlineType", CFU_UNDERLINEWAVE - CFU_UNDERLINEDOUBLE }, + { &opts.cascade_corrections, CONTROL_CHECKBOX, IDC_CASCADE_CORRECTIONS, "CascadeCorrections", FALSE }, + { &opts.show_all_corrections, CONTROL_CHECKBOX, IDC_SHOW_ALL_CORRECTIONS, "ShowAllCorrections", FALSE }, + { &opts.show_wrong_word, CONTROL_CHECKBOX, IDC_SHOW_WRONG_WORD, "ShowWrongWord", TRUE }, + { &opts.use_flags, CONTROL_CHECKBOX, IDC_USE_FLAGS, "UseFlags", TRUE }, + { &opts.auto_locale, CONTROL_CHECKBOX, IDC_AUTO_LOCALE, "AutoLocale", FALSE }, + { &opts.use_other_apps_dicts, CONTROL_CHECKBOX, IDC_OTHER_PROGS, "UseOtherAppsDicts", TRUE }, + { &opts.handle_underscore, CONTROL_CHECKBOX, IDC_HANDLE_UNDERSCORE, "HandleUnderscore", FALSE }, }; -static UINT optionsExpertControls[] = { +static UINT optionsExpertControls[] = { IDC_ADVANCED, IDC_UNDERLINE_TYPE_L, IDC_UNDERLINE_TYPE, IDC_CASCADE_CORRECTIONS, IDC_SHOW_ALL_CORRECTIONS, IDC_SHOW_WRONG_WORD, IDC_USE_FLAGS, IDC_AUTO_LOCALE, IDC_OTHER_PROGS, IDC_HANDLE_UNDERSCORE }; -static OptPageControl autoReplaceControls[] = { - { &opts.auto_replace_user, CONTROL_CHECKBOX, IDC_AUTO_USER, "AutoReplaceUser", TRUE }, +static OptPageControl autoReplaceControls[] = { + { &opts.auto_replace_user, CONTROL_CHECKBOX, IDC_AUTO_USER, "AutoReplaceUser", TRUE }, }; // Functions ////////////////////////////////////////////////////////////////////////////////////// -int InitOptionsCallback(WPARAM wParam,LPARAM) +int InitOptionsCallback(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { sizeof(odp) }; odp.hInstance = hInst; @@ -79,7 +79,7 @@ int InitOptionsCallback(WPARAM wParam,LPARAM) void InitOptions() { LoadOptions(); - + HookEvent(ME_OPT_INITIALISE, InitOptionsCallback); } @@ -87,7 +87,7 @@ void LoadOptions() { LoadOpts(optionsControls, SIZEOF(optionsControls), MODULE_NAME); LoadOpts(autoReplaceControls, SIZEOF(autoReplaceControls), MODULE_NAME); - + if (languages.getCount() <= 0) { opts.default_language[0] = _T('\0'); return; @@ -100,7 +100,7 @@ void LoadOptions() } int i; - for(i = 0; i < languages.getCount(); i++) + for (i = 0; i < languages.getCount(); i++) if (mir_tstrcmp(languages[i]->language, opts.default_language) == 0) break; @@ -108,7 +108,7 @@ void LoadOptions() mir_tstrcpy(opts.default_language, languages[0]->language); } -static void DrawItem(HWND hwndDlg, LPDRAWITEMSTRUCT lpdis, Dictionary *dict) +static void DrawItem(LPDRAWITEMSTRUCT lpdis, Dictionary *dict) { TEXTMETRIC tm; RECT rc; @@ -129,8 +129,8 @@ static void DrawItem(HWND hwndDlg, LPDRAWITEMSTRUCT lpdis, Dictionary *dict) backIndex = COLOR_WINDOW; } - COLORREF clrfore = SetTextColor(lpdis->hDC,GetSysColor(foreIndex)); - COLORREF clrback = SetBkColor(lpdis->hDC,GetSysColor(backIndex)); + COLORREF clrfore = SetTextColor(lpdis->hDC, GetSysColor(foreIndex)); + COLORREF clrback = SetBkColor(lpdis->hDC, GetSysColor(backIndex)); FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(backIndex)); @@ -144,7 +144,7 @@ static void DrawItem(HWND hwndDlg, LPDRAWITEMSTRUCT lpdis, Dictionary *dict) DrawIconEx(lpdis->hDC, rc.left, rc.top, hFlag, 16, 16, 0, NULL, DI_NORMAL); rc.left += ICON_SIZE + 4; - + Skin_ReleaseIcon(hFlag); } @@ -170,30 +170,30 @@ static void MeasureItem(HWND hwndDlg, LPMEASUREITEMSTRUCT lpmis) lpmis->itemHeight = tm.tmHeight; } -static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: - { - int sel = -1; - for(int i = 0; i < languages.getCount(); i++) { - SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_ADDSTRING, 0, (LPARAM)languages[i]->full_name); - SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_SETITEMDATA, i, (LPARAM)languages[i]); - - if ( !mir_tstrcmp(opts.default_language, languages[i]->language)) - sel = i; - } - SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_SETCURSEL, sel, 0); - - SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Line")); - SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dotted")); - SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dash")); - SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dash dot")); - SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dash dot dot")); - SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Wave")); - SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Thick")); + { + int sel = -1; + for (int i = 0; i < languages.getCount(); i++) { + SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_ADDSTRING, 0, (LPARAM)languages[i]->full_name); + SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_SETITEMDATA, i, (LPARAM)languages[i]); + + if (!mir_tstrcmp(opts.default_language, languages[i]->language)) + sel = i; } - break; + SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_SETCURSEL, sel, 0); + + SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Line")); + SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dotted")); + SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dash")); + SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dash dot")); + SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Dash dot dot")); + SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Wave")); + SendDlgItemMessage(hwndDlg, IDC_UNDERLINE_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateT("Thick")); + } + break; case WM_COMMAND: if (LOWORD(wParam) == IDC_GETMORE) @@ -207,35 +207,35 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP break; case WM_NOTIFY: - { - LPNMHDR lpnmhdr = (LPNMHDR)lParam; - if (lpnmhdr->idFrom == 0 && lpnmhdr->code == PSN_APPLY && languages.getCount() > 0) { - int sel = SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_GETCURSEL, 0, 0); - if (sel >= languages.getCount()) - sel = 0; - db_set_ts(NULL, MODULE_NAME, "DefaultLanguage", - (TCHAR *) languages[sel]->language); - mir_tstrcpy(opts.default_language, languages[sel]->language); - } + { + LPNMHDR lpnmhdr = (LPNMHDR)lParam; + if (lpnmhdr->idFrom == 0 && lpnmhdr->code == PSN_APPLY && languages.getCount() > 0) { + int sel = SendDlgItemMessage(hwndDlg, IDC_DEF_LANG, CB_GETCURSEL, 0, 0); + if (sel >= languages.getCount()) + sel = 0; + db_set_ts(NULL, MODULE_NAME, "DefaultLanguage", + (TCHAR *)languages[sel]->language); + mir_tstrcpy(opts.default_language, languages[sel]->language); } - break; + } + break; case WM_DRAWITEM: - { - LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; - if (lpdis->CtlID != IDC_DEF_LANG) - break; - if (lpdis->itemID == -1) - break; + { + LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; + if (lpdis->CtlID != IDC_DEF_LANG) + break; + if (lpdis->itemID == -1) + break; - Dictionary *dict = (Dictionary *) lpdis->itemData; - DrawItem(hwndDlg, lpdis, dict); - } - return TRUE; + Dictionary *dict = (Dictionary *)lpdis->itemData; + DrawItem(lpdis, dict); + } + return TRUE; case WM_MEASUREITEM: LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam; - if (lpmis->CtlID != IDC_DEF_LANG) + if (lpmis->CtlID != IDC_DEF_LANG) break; MeasureItem(hwndDlg, lpmis); @@ -256,10 +256,10 @@ struct AutoreplaceData void RemoveWord(const TCHAR *aWord) { - map::iterator it = autoReplaceMap.find(aWord); - if (it != autoReplaceMap.end()) - autoReplaceMap.erase(it); - changed = TRUE; + map::iterator it = autoReplaceMap.find(aWord); + if (it != autoReplaceMap.end()) + autoReplaceMap.erase(it); + changed = TRUE; } void AddWord(const TCHAR *find, const TCHAR *replace, BOOL useVars) @@ -297,37 +297,37 @@ static void LoadReplacements(HWND hwndDlg) if (sel < 0) return; - AutoreplaceData *data = (AutoreplaceData *) SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, sel, 0); + AutoreplaceData *data = (AutoreplaceData *)SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, sel, 0); if (!data->initialized) { data->dict->autoReplace->copyMap(&data->autoReplaceMap); data->initialized = TRUE; } - map::iterator it = data->autoReplaceMap.begin(); - for(int i = 0; it != data->autoReplaceMap.end(); it++, i++) { - LVITEM item = {0}; + map::iterator it = data->autoReplaceMap.begin(); + for (int i = 0; it != data->autoReplaceMap.end(); it++, i++) { + LVITEM item = { 0 }; item.mask = LVIF_TEXT | LVIF_PARAM; item.iItem = i; item.iSubItem = 0; - item.pszText = (TCHAR *) it->first.c_str(); + item.pszText = (TCHAR *)it->first.c_str(); item.lParam = i; - + ListView_InsertItem(hList, &item); - ListView_SetItemText(hList, i, 1, (TCHAR *) it->second.replace.c_str()); + ListView_SetItemText(hList, i, 1, (TCHAR *)it->second.replace.c_str()); } EnableDisableCtrls(hwndDlg); } -static void SaveNewReplacements(BOOL canceled, Dictionary *dict, - const TCHAR *find, const TCHAR *replace, BOOL useVariables, - const TCHAR *original_find, void *param) +static void SaveNewReplacements(BOOL canceled, Dictionary *dict, + const TCHAR *find, const TCHAR *replace, BOOL useVariables, + const TCHAR *original_find, void *param) { if (canceled) return; - AutoreplaceData *data = (AutoreplaceData *) param; + AutoreplaceData *data = (AutoreplaceData *)param; if (mir_tstrlen(original_find) > 0) data->RemoveWord(original_find); @@ -341,7 +341,7 @@ static void ShowAddReplacement(HWND hwndDlg, int item = -1) if (sel < 0) return; - AutoreplaceData *data = (AutoreplaceData *) SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, sel, 0); + AutoreplaceData *data = (AutoreplaceData *)SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, sel, 0); TCHAR find[256]; const TCHAR *replace = NULL; @@ -362,45 +362,45 @@ static void ShowAddReplacement(HWND hwndDlg, int item = -1) LoadReplacements(hwndDlg); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } - + EnableDisableCtrls(hwndDlg); } -static INT_PTR CALLBACK AutoreplaceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK AutoreplaceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: - { - BOOL ret = SaveOptsDlgProc(autoReplaceControls, SIZEOF(autoReplaceControls), MODULE_NAME, hwndDlg, msg, wParam, lParam); + { + BOOL ret = SaveOptsDlgProc(autoReplaceControls, SIZEOF(autoReplaceControls), MODULE_NAME, hwndDlg, msg, wParam, lParam); - int sel = -1; - for(int i = 0; i < languages.getCount(); i++) { - Dictionary *p = languages[i]; - SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)p->full_name); - SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, i, (LPARAM)new AutoreplaceData(p)); + int sel = -1; + for (int i = 0; i < languages.getCount(); i++) { + Dictionary *p = languages[i]; + SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)p->full_name); + SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETITEMDATA, i, (LPARAM)new AutoreplaceData(p)); - if ( !mir_tstrcmp(opts.default_language, p->language)) - sel = i; - } - SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETCURSEL, sel, 0); + if (!mir_tstrcmp(opts.default_language, p->language)) + sel = i; + } + SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_SETCURSEL, sel, 0); - HWND hList = GetDlgItem(hwndDlg, IDC_REPLACEMENTS); + HWND hList = GetDlgItem(hwndDlg, IDC_REPLACEMENTS); - ListView_SetExtendedListViewStyle(hList, ListView_GetExtendedListViewStyle(hList) | LVS_EX_FULLROWSELECT); + ListView_SetExtendedListViewStyle(hList, ListView_GetExtendedListViewStyle(hList) | LVS_EX_FULLROWSELECT); - LVCOLUMN col = {0}; - col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT ; - col.fmt = LVCFMT_LEFT; - col.cx = 175; - col.pszText = TranslateT("Wrong word"); - ListView_InsertColumn(hList, 0, &col); + LVCOLUMN col = { 0 }; + col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT; + col.fmt = LVCFMT_LEFT; + col.cx = 175; + col.pszText = TranslateT("Wrong word"); + ListView_InsertColumn(hList, 0, &col); - col.pszText = TranslateT("Correction"); - ListView_InsertColumn(hList, 1, &col); + col.pszText = TranslateT("Correction"); + ListView_InsertColumn(hList, 1, &col); - LoadReplacements(hwndDlg); - return ret; - } + LoadReplacements(hwndDlg); + return ret; + } case WM_COMMAND: if (LOWORD(wParam) == IDC_LANGUAGE && HIWORD(wParam) == CBN_SELCHANGE) @@ -425,12 +425,12 @@ static INT_PTR CALLBACK AutoreplaceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam if (sel < 0) break; - AutoreplaceData *data = (AutoreplaceData *) SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, sel, 0); + AutoreplaceData *data = (AutoreplaceData *)SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, sel, 0); BOOL changed = FALSE; sel = SendMessage(hList, LVM_GETNEXTITEM, -1, LVNI_SELECTED); - while(sel >= 0) { + while (sel >= 0) { TCHAR tmp[256]; ListView_GetItemText(hList, sel, 0, tmp, SIZEOF(tmp)); @@ -448,54 +448,52 @@ static INT_PTR CALLBACK AutoreplaceDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam break; case WM_NOTIFY: - { - LPNMHDR lpnmhdr = (LPNMHDR)lParam; - if (lpnmhdr->idFrom == 0 && lpnmhdr->code == PSN_APPLY && languages.getCount() > 0) { - for(int i = 0; i < languages.getCount(); i++) { - AutoreplaceData *data = (AutoreplaceData *) SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, i, 0); - if (data->changed) { - data->dict->autoReplace->setMap(data->autoReplaceMap); - data->changed = FALSE; - } - } - } - else if (lpnmhdr->idFrom == IDC_REPLACEMENTS) { - HWND hList = GetDlgItem(hwndDlg, IDC_REPLACEMENTS); - - switch(lpnmhdr->code) { - case LVN_ITEMCHANGED: - case NM_CLICK: - EnableDisableCtrls(hwndDlg); - break; - - case NM_DBLCLK: - LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; - if (lpnmitem->iItem >= 0) - ShowAddReplacement(hwndDlg, lpnmitem->iItem); - break; + { + LPNMHDR lpnmhdr = (LPNMHDR)lParam; + if (lpnmhdr->idFrom == 0 && lpnmhdr->code == PSN_APPLY && languages.getCount() > 0) { + for (int i = 0; i < languages.getCount(); i++) { + AutoreplaceData *data = (AutoreplaceData *)SendDlgItemMessage(hwndDlg, IDC_LANGUAGE, CB_GETITEMDATA, i, 0); + if (data->changed) { + data->dict->autoReplace->setMap(data->autoReplaceMap); + data->changed = FALSE; } } - else if (lpnmhdr->idFrom == IDC_AUTO_USER) + } + else if (lpnmhdr->idFrom == IDC_REPLACEMENTS) { + switch (lpnmhdr->code) { + case LVN_ITEMCHANGED: + case NM_CLICK: EnableDisableCtrls(hwndDlg); + break; + + case NM_DBLCLK: + LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE)lParam; + if (lpnmitem->iItem >= 0) + ShowAddReplacement(hwndDlg, lpnmitem->iItem); + break; + } } - break; + else if (lpnmhdr->idFrom == IDC_AUTO_USER) + EnableDisableCtrls(hwndDlg); + } + break; case WM_DRAWITEM: - { - LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; - if (lpdis->CtlID != IDC_LANGUAGE) - break; - if (lpdis->itemID == -1) - break; + { + LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; + if (lpdis->CtlID != IDC_LANGUAGE) + break; + if (lpdis->itemID == -1) + break; - AutoreplaceData *data = (AutoreplaceData *) lpdis->itemData; - DrawItem(hwndDlg, lpdis, data->dict); - } - return TRUE; + AutoreplaceData *data = (AutoreplaceData *)lpdis->itemData; + DrawItem(lpdis, data->dict); + } + return TRUE; case WM_MEASUREITEM: LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam; - if (lpmis->CtlID != IDC_LANGUAGE) + if (lpmis->CtlID != IDC_LANGUAGE) break; MeasureItem(hwndDlg, lpmis); diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp index b1dabfd562..f0191cbabc 100644 --- a/plugins/SpellChecker/src/spellchecker.cpp +++ b/plugins/SpellChecker/src/spellchecker.cpp @@ -1,4 +1,4 @@ -/* +/* Copyright (C) 2006-2010 Ricardo Pescuma Domenecci This is free software; you can redistribute it and/or @@ -14,14 +14,14 @@ Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this file; see the file license.txt. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. +Boston, MA 02111-1307, USA. */ #include "commons.h" // Prototypes /////////////////////////////////////////////////////////////////////////// -PLUGININFOEX pluginInfo={ +PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), __PLUGIN_NAME, PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), @@ -32,7 +32,7 @@ PLUGININFOEX pluginInfo={ __AUTHORWEB, UNICODE_AWARE, // {36753AE3-840B-4797-94A5-FD9F5852B942} - {0x36753ae3, 0x840b, 0x4797, {0x94, 0xa5, 0xfd, 0x9f, 0x58, 0x52, 0xb9, 0x42}} + { 0x36753ae3, 0x840b, 0x4797, { 0x94, 0xa5, 0xfd, 0x9f, 0x58, 0x52, 0xb9, 0x42 } } }; HINSTANCE hInst; @@ -58,13 +58,13 @@ LIST languages(1); // Functions //////////////////////////////////////////////////////////////////////////// -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) { hInst = hinstDLL; return TRUE; } -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { return &pluginInfo; } diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp index 060f05804a..b7a2dc4018 100644 --- a/plugins/SpellChecker/src/utils.cpp +++ b/plugins/SpellChecker/src/utils.cpp @@ -707,7 +707,7 @@ int GetClosestLanguage(TCHAR *lang_name) if (p == NULL) continue; - int prefix_len = p - languages[i]->language; + size_t prefix_len = p - languages[i]->language; if (prefix_len != len) continue; @@ -867,7 +867,7 @@ void ModifyIcon(Dialog *dlg) } } -INT_PTR AddContactTextBoxService(WPARAM wParam, LPARAM lParam) +INT_PTR AddContactTextBoxService(WPARAM wParam, LPARAM) { SPELLCHECKER_ITEM *sci = (SPELLCHECKER_ITEM *)wParam; if (sci == NULL || sci->cbSize != sizeof(SPELLCHECKER_ITEM)) @@ -947,7 +947,7 @@ void FreePopupData(Dialog *dlg) } } -INT_PTR RemoveContactTextBoxService(WPARAM wParam, LPARAM lParam) +INT_PTR RemoveContactTextBoxService(WPARAM wParam, LPARAM) { HWND hwnd = (HWND)wParam; if (hwnd == NULL) @@ -1149,8 +1149,6 @@ void AddItemsToMenu(Dialog *dlg, HMENU hMenu, POINT pt, HWND hwndOwner) menus[hwndOwner] = dlg; } - BOOL wrong_word = FALSE; - // Make menu if (GetMenuItemCount(hMenu) > 0) InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); @@ -1283,7 +1281,7 @@ BOOL HandleMenuSelection(Dialog *dlg, POINT pt, unsigned selection) return ret; } -int MsgWindowPopup(WPARAM wParam, LPARAM lParam) +int MsgWindowPopup(WPARAM, LPARAM lParam) { MessageWindowPopupData *mwpd = (MessageWindowPopupData *)lParam; if (mwpd == NULL || mwpd->cbSize < sizeof(MessageWindowPopupData) || mwpd->uFlags != MSG_WINDOWPOPUP_INPUT) @@ -1306,7 +1304,7 @@ int MsgWindowPopup(WPARAM wParam, LPARAM lParam) return 0; } -INT_PTR ShowPopupMenuService(WPARAM wParam, LPARAM lParam) +INT_PTR ShowPopupMenuService(WPARAM wParam, LPARAM) { SPELLCHECKER_POPUPMENU *scp = (SPELLCHECKER_POPUPMENU *)wParam; if (scp == NULL || scp->cbSize != sizeof(SPELLCHECKER_POPUPMENU)) @@ -1354,7 +1352,7 @@ int ShowPopupMenu(HWND hwnd, HMENU hMenu, POINT pt, HWND hwndOwner) return selection; } -int MsgWindowEvent(WPARAM wParam, LPARAM lParam) +int MsgWindowEvent(WPARAM, LPARAM lParam) { MessageWindowEventData *event = (MessageWindowEventData *)lParam; if (event == NULL) @@ -1437,8 +1435,6 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (dlgit == menus.end()) return -1; - Dialog *dlg = dlgit->second; - switch (msg) { case WM_INITMENUPOPUP: { -- cgit v1.2.3