diff options
author | George Hazan <george.hazan@gmail.com> | 2014-05-22 14:31:16 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-05-22 14:31:16 +0000 |
commit | 794b3c318b582abb7eab83dd9a32c9a894048b0b (patch) | |
tree | dd4bc56f8c70d9366295ae5fad9ec18048b55a36 | |
parent | 6d6d5591b1ee1002ccf1da0f98942f7aa78ccb80 (diff) |
- unused error message removed;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@9277 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/SpellChecker/src/RichEdit.cpp | 28 | ||||
-rw-r--r-- | plugins/SpellChecker/src/ardialog.cpp | 106 | ||||
-rw-r--r-- | plugins/SpellChecker/src/autoreplace.cpp | 79 | ||||
-rw-r--r-- | plugins/SpellChecker/src/dictionary.cpp | 207 | ||||
-rw-r--r-- | plugins/SpellChecker/src/options.cpp | 2 | ||||
-rw-r--r-- | plugins/SpellChecker/src/utils.cpp | 255 |
6 files changed, 285 insertions, 392 deletions
diff --git a/plugins/SpellChecker/src/RichEdit.cpp b/plugins/SpellChecker/src/RichEdit.cpp index cd15c18b04..53ed48ca30 100644 --- a/plugins/SpellChecker/src/RichEdit.cpp +++ b/plugins/SpellChecker/src/RichEdit.cpp @@ -4,8 +4,7 @@ const GUID CDECL name \
= { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
-DEFINE_GUIDXXX(IID_ITextDocument,0x8CC497C0,0xA1DF,0x11CE,0x80,0x98,
- 0x00,0xAA,0x00,0x47,0xBE,0x5D);
+DEFINE_GUIDXXX(IID_ITextDocument,0x8CC497C0,0xA1DF,0x11CE,0x80,0x98,0x00,0xAA,0x00,0x47,0xBE,0x5D);
RichEdit::RichEdit(HWND hwnd)
: hwnd(NULL), ole(NULL), textDocument(NULL), stopped(0), undoEnabled(TRUE)
@@ -46,7 +45,7 @@ void RichEdit::SetHWND(HWND hwnd) if (hwnd == NULL)
return;
- SendMessage(EM_GETOLEINTERFACE, 0, (LPARAM) &ole);
+ SendMessage(EM_GETOLEINTERFACE, 0, (LPARAM)&ole);
if (ole == NULL)
return;
@@ -90,17 +89,16 @@ void RichEdit::Stop() SuspendUndo();
-// HideCaret(hwnd);
SendMessage(WM_SETREDRAW, FALSE, 0);
- SendMessage(EM_GETSCROLLPOS, 0, (LPARAM) &old_scroll_pos);
- SendMessage(EM_EXGETSEL, 0, (LPARAM) &old_sel);
+ SendMessage(EM_GETSCROLLPOS, 0, (LPARAM)&old_scroll_pos);
+ SendMessage(EM_EXGETSEL, 0, (LPARAM)&old_sel);
GetCaretPos(&caretPos);
old_mask = SendMessage(EM_GETEVENTMASK, 0, 0);
SendMessage(EM_SETEVENTMASK, 0, old_mask & ~ENM_CHANGE);
- inverse = (old_sel.cpMin >= LOWORD(SendMessage(EM_CHARFROMPOS, 0, (LPARAM) &caretPos)));
+ inverse = (old_sel.cpMin >= LOWORD(SendMessage(EM_CHARFROMPOS, 0, (LPARAM)&caretPos)));
}
void RichEdit::Start()
@@ -123,8 +121,8 @@ void RichEdit::Start() }
SendMessage(EM_SETEVENTMASK, 0, old_mask);
- SendMessage(EM_EXSETSEL, 0, (LPARAM) &old_sel);
- SendMessage(EM_SETSCROLLPOS, 0, (LPARAM) &old_scroll_pos);
+ SendMessage(EM_EXSETSEL, 0, (LPARAM)&old_sel);
+ SendMessage(EM_SETSCROLLPOS, 0, (LPARAM)&old_scroll_pos);
SendMessage(WM_SETREDRAW, TRUE, 0);
InvalidateRect(hwnd, NULL, FALSE);
@@ -140,7 +138,7 @@ BOOL RichEdit::IsStopped() int RichEdit::GetCharFromPos(const POINT &pt)
{
- return LOWORD(SendMessage(EM_CHARFROMPOS, 0, (LPARAM) &pt));
+ return LOWORD(SendMessage(EM_CHARFROMPOS, 0, (LPARAM)&pt));
}
int RichEdit::GetLineCount() const
@@ -151,7 +149,7 @@ int RichEdit::GetLineCount() const void RichEdit::GetLine(int line, TCHAR *text, size_t text_len) const
{
*((WORD*)text) = WORD(text_len - 1);
- unsigned size = (unsigned) SendMessage(EM_GETLINE, (WPARAM) line, (LPARAM) text);
+ unsigned size = (unsigned) SendMessage(EM_GETLINE, (WPARAM) line, (LPARAM)text);
// Sometimes it likes to return size = lineLen+1, adding an \n at the end, so we remove it here
// to make both implementations return same size
int lineLen = GetLineLength(line);
@@ -177,7 +175,7 @@ int RichEdit::GetLineFromChar(int charPos) const CHARRANGE RichEdit::GetSel() const
{
CHARRANGE sel;
- SendMessage(EM_EXGETSEL, 0, (LPARAM) &sel);
+ SendMessage(EM_EXGETSEL, 0, (LPARAM)&sel);
return sel;
}
@@ -189,7 +187,7 @@ void RichEdit::SetSel(int start, int end) void RichEdit::SetSel(const CHARRANGE &sel)
{
- SendMessage(EM_EXSETSEL, 0, (LPARAM) &sel);
+ SendMessage(EM_EXSETSEL, 0, (LPARAM)&sel);
}
int RichEdit::GetTextLength() const
@@ -247,7 +245,7 @@ void RichEdit::ReplaceSel(const TCHAR *new_text) ResumeUndo();
- SendMessage(EM_REPLACESEL, undoEnabled, (LPARAM) new_text);
+ SendMessage(EM_REPLACESEL, undoEnabled, (LPARAM)new_text);
SuspendUndo();
@@ -258,7 +256,7 @@ void RichEdit::ReplaceSel(const TCHAR *new_text) }
else
{
- SendMessage(EM_REPLACESEL, undoEnabled, (LPARAM) new_text);
+ SendMessage(EM_REPLACESEL, undoEnabled, (LPARAM)new_text);
}
}
diff --git a/plugins/SpellChecker/src/ardialog.cpp b/plugins/SpellChecker/src/ardialog.cpp index cfaacbb770..22634c8858 100644 --- a/plugins/SpellChecker/src/ardialog.cpp +++ b/plugins/SpellChecker/src/ardialog.cpp @@ -37,8 +37,8 @@ struct Data };
BOOL ShowAutoReplaceDialog(HWND parent, BOOL modal,
- Dictionary *dict, const TCHAR *find, const TCHAR *replace, BOOL useVariables,
- BOOL findReadOnly, AutoReplaceDialogCallback callback, void *param)
+ Dictionary *dict, const TCHAR *find, const TCHAR *replace, BOOL useVariables,
+ BOOL findReadOnly, AutoReplaceDialogCallback callback, void *param)
{
Data *data = new Data();
data->dict = dict;
@@ -55,20 +55,14 @@ BOOL ShowAutoReplaceDialog(HWND parent, BOOL modal, data->replace = replace;
if (modal)
- {
- return DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ADD_REPLACEMENT), parent,
- AddReplacementDlgProc, (LPARAM) data);
- }
- else
- {
- HWND hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_REPLACEMENT), parent,
- AddReplacementDlgProc, (LPARAM) data);
- SetForegroundWindow(hwnd);
- SetFocus(hwnd);
- SetFocus(GetDlgItem(hwnd, IDC_NEW));
- ShowWindow(hwnd, SW_SHOW);
- return TRUE;
- }
+ return DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ADD_REPLACEMENT), parent, AddReplacementDlgProc, (LPARAM)data);
+
+ HWND hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_REPLACEMENT), parent, AddReplacementDlgProc, (LPARAM)data);
+ SetForegroundWindow(hwnd);
+ SetFocus(hwnd);
+ SetFocus(GetDlgItem(hwnd, IDC_NEW));
+ ShowWindow(hwnd, SW_SHOW);
+ return TRUE;
}
@@ -102,20 +96,17 @@ static LRESULT CALLBACK OnlyCharsEditProc(HWND hwnd, UINT msg, WPARAM wParam, LP switch(msg) {
case EM_PASTESPECIAL:
case WM_PASTE:
- {
- TCHAR text[256];
- GetWindowText(hwnd, text, SIZEOF(text));
+ TCHAR text[256];
+ GetWindowText(hwnd, text, SIZEOF(text));
- scoped_free<TCHAR> dest = data->dict->autoReplace->filterText(text);
- SetWindowText(hwnd, dest);
- break;
- }
+ scoped_free<TCHAR> dest = data->dict->autoReplace->filterText(text);
+ SetWindowText(hwnd, dest);
+ break;
}
return ret;
}
-
static BOOL CenterParent(HWND hwnd)
{
HWND hwndParent = GetParent(hwnd);
@@ -126,16 +117,16 @@ static BOOL CenterParent(HWND hwnd) GetWindowRect(hwnd, &rect);
GetWindowRect(hwndParent, &rectP);
- int width = rect.right - rect.left;
+ int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
- int x = ((rectP.right-rectP.left) - width) / 2 + rectP.left;
- int y = ((rectP.bottom-rectP.top) - height) / 2 + rectP.top;
+ int x = ((rectP.right - rectP.left) - width) / 2 + rectP.left;
+ int y = ((rectP.bottom - rectP.top) - height) / 2 + rectP.top;
- int screenwidth = GetSystemMetrics(SM_CXSCREEN);
+ int screenwidth = GetSystemMetrics(SM_CXSCREEN);
int screenheight = GetSystemMetrics(SM_CYSCREEN);
- if (x + width > screenwidth) x = screenwidth - width;
+ if (x + width > screenwidth) x = screenwidth - width;
if (y + height > screenheight) y = screenheight - height;
if (x < 0) x = 0;
if (y < 0) y = 0;
@@ -147,12 +138,12 @@ static BOOL CenterParent(HWND hwnd) static void Close(HWND hwndDlg, int ret)
{
- Data *data = (Data *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Data *data = (Data *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (!ret)
- data->callback(TRUE, data->dict,
- data->find.c_str(), data->replace.c_str(), data->useVariables,
- data->find.c_str(), data->param);
+ data->callback(TRUE, data->dict,
+ data->find.c_str(), data->replace.c_str(), data->useVariables,
+ data->find.c_str(), data->param);
if (data->modal)
EndDialog(hwndDlg, ret);
@@ -168,14 +159,14 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
- Data *data = (Data *) lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) data);
+ Data *data = (Data *)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)data);
- SetWindowLongPtr( GetDlgItem(hwndDlg, IDC_OLD), GWLP_USERDATA, (LONG_PTR)data);
- mir_subclassWindow( GetDlgItem(hwndDlg, IDC_OLD), OnlyCharsEditProc);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_OLD), GWLP_USERDATA, (LONG_PTR)data);
+ mir_subclassWindow(GetDlgItem(hwndDlg, IDC_OLD), OnlyCharsEditProc);
HICON hIcon = Skin_GetIcon("spellchecker_enabled");
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
Skin_ReleaseIcon(hIcon);
SendDlgItemMessage(hwndDlg, IDC_OLD, EM_LIMITTEXT, 256, 0);
@@ -205,9 +196,9 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa GetWindowRect(GetDlgItem(hwndDlg, IDC_NEW), &rc_new);
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);
+ 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);
}
else {
variables_skin_helpbutton(hwndDlg, IDC_VAR_HELP);
@@ -219,10 +210,10 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa return TRUE;
case WM_COMMAND:
- switch(wParam) {
+ switch (wParam) {
case IDOK:
{
- Data *data = (Data *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Data *data = (Data *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
TCHAR find[256];
if (data->findReadOnly)
@@ -236,22 +227,19 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa 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);
- }
+ 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);
+ data->callback(FALSE, data->dict,
+ find, replace, IsDlgButtonChecked(hwndDlg, IDC_VARIABLES),
+ data->find.c_str(), data->param);
Close(hwndDlg, 1);
}
}
@@ -275,6 +263,6 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa Close(hwndDlg, 0);
break;
}
-
+
return FALSE;
}
diff --git a/plugins/SpellChecker/src/autoreplace.cpp b/plugins/SpellChecker/src/autoreplace.cpp index 11aac5c310..aa38708d8a 100644 --- a/plugins/SpellChecker/src/autoreplace.cpp +++ b/plugins/SpellChecker/src/autoreplace.cpp @@ -40,38 +40,32 @@ AutoReplaceMap::AutoReplaceMap(TCHAR *aFilename, Dictionary *dict) void AutoReplaceMap::loadAutoReplaceMap()
{
FILE *file = _tfopen(filename, _T("rb"));
- if (file == NULL)
+ if (file == NULL)
return;
char tmp[1024];
char c;
int pos = 0;
- while((c = fgetc(file)) != EOF)
- {
- if (c == '\n' || c == '\r' || pos >= SIZEOF(tmp) - 1)
- {
- if (pos > 0)
- {
+ while ((c = fgetc(file)) != EOF) {
+ if (c == '\n' || c == '\r' || pos >= SIZEOF(tmp) - 1) {
+ if (pos > 0) {
tmp[pos] = '\0';
// Get from
BOOL useVars;
char *p;
- if ((p = strstr(tmp, "->")) != NULL)
- {
+ if ((p = strstr(tmp, "->")) != NULL) {
*p = '\0';
p += 2;
useVars = FALSE;
}
- else if ((p = strstr(tmp, "-V>")) != NULL)
- {
+ else if ((p = strstr(tmp, "-V>")) != NULL) {
*p = '\0';
p += 3;
useVars = TRUE;
}
- if (p != NULL)
- {
+ if (p != NULL) {
Utf8ToTchar find(tmp);
Utf8ToTchar replace(p);
@@ -85,10 +79,9 @@ void AutoReplaceMap::loadAutoReplaceMap() pos = 0;
}
- else
- {
+ else {
tmp[pos] = c;
- pos ++;
+ pos++;
}
}
fclose(file);
@@ -98,8 +91,7 @@ void AutoReplaceMap::writeAutoReplaceMap() {
// Create path
TCHAR *p = _tcsrchr(filename, _T('\\'));
- if (p != NULL)
- {
+ if (p != NULL) {
*p = 0;
CreateDirectoryTreeT(filename);
*p = _T('\\');
@@ -107,11 +99,9 @@ void AutoReplaceMap::writeAutoReplaceMap() // Write it
FILE *file = _tfopen(filename, _T("wb"));
- if (file != NULL)
- {
- map<tstring,AutoReplacement>::iterator it = replacements.begin();
- for (; it != replacements.end(); it++)
- {
+ if (file != NULL) {
+ map<tstring, AutoReplacement>::iterator it = replacements.begin();
+ for (; it != replacements.end(); it++) {
AutoReplacement &ar = it->second;
TcharToUtf8 find(it->first.c_str());
@@ -139,7 +129,7 @@ BOOL AutoReplaceMap::isWordChar(TCHAR c) }
-TCHAR * AutoReplaceMap::autoReplace(const TCHAR * word)
+TCHAR* AutoReplaceMap::autoReplace(const TCHAR * word)
{
scoped_free<TCHAR> from = _tcslwr(_tcsdup(word));
@@ -150,7 +140,7 @@ TCHAR * AutoReplaceMap::autoReplace(const TCHAR * word) TCHAR *to;
if (ar.useVariables)
- to = variables_parsedup((TCHAR *) ar.replace.c_str(), (TCHAR *) word, NULL);
+ to = variables_parsedup((TCHAR *)ar.replace.c_str(), (TCHAR *)word, NULL);
else
to = _tcsdup(ar.replace.c_str());
@@ -161,34 +151,27 @@ TCHAR * AutoReplaceMap::autoReplace(const TCHAR * word) if (IsCharLower(word[i]))
break;
- if (i <= 0)
- {
- // All lower
+ if (i <= 0) // All lower
return to;
- }
- else if (i >= len)
- {
- // All upper
+
+ if (i >= len) // All upper
return CharUpper(to);
- }
- else
- {
- // First upper
- TCHAR tmp[2];
- tmp[0] = to[0];
- tmp[1] = _T('\0');
- CharUpper(tmp);
- to[0] = tmp[0];
- return to;
- }
+
+ // First upper
+ TCHAR tmp[2];
+ tmp[0] = to[0];
+ tmp[1] = _T('\0');
+ CharUpper(tmp);
+ to[0] = tmp[0];
+ return to;
}
-TCHAR * AutoReplaceMap::filterText(const TCHAR *find)
+TCHAR* AutoReplaceMap::filterText(const TCHAR *find)
{
TCHAR *ret = _tcsdup(find);
int len = lstrlen(ret);
int pos = 0;
- for(int i = 0; i < len; i++)
+ for (int i = 0; i < len; i++)
if (isWordChar(find[i]))
ret[pos++] = ret[i];
ret[pos] = 0;
@@ -214,14 +197,10 @@ void AutoReplaceMap::setMap(const map<tstring, AutoReplacement> &replacements) this->replacements.clear();
map<tstring, AutoReplacement>::const_iterator it = replacements.begin();
- for (; it != replacements.end(); it++)
- {
+ for (; it != replacements.end(); it++) {
scoped_free<TCHAR> from = filterText(it->first.c_str());
this->replacements[from.get()] = it->second;
}
writeAutoReplaceMap();
}
-
-
-
diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp index 25639508c9..cd27a3fd78 100644 --- a/plugins/SpellChecker/src/dictionary.cpp +++ b/plugins/SpellChecker/src/dictionary.cpp @@ -352,7 +352,8 @@ struct { void LoadThread(LPVOID hd);
-class HunspellDictionary : public Dictionary {
+class HunspellDictionary : public Dictionary
+{
protected:
TCHAR fileWithoutExtension[1024];
TCHAR userPath[1024];
@@ -367,27 +368,22 @@ protected: mir_sntprintf(filename, SIZEOF(filename), _T("%s\\%s.cdic"), userPath, language);
FILE *file = _tfopen(filename, _T("rb"));
- if (file != NULL)
- {
+ if (file != NULL) {
char tmp[1024];
char c;
int pos = 0;
- while((c = fgetc(file)) != EOF)
- {
- if (c == '\n' || c == '\r' || pos >= SIZEOF(tmp) - 1)
- {
- if (pos > 0)
- {
+ while ((c = fgetc(file)) != EOF) {
+ if (c == '\n' || c == '\r' || pos >= SIZEOF(tmp) - 1) {
+ if (pos > 0) {
tmp[pos] = '\0';
hunspell->add(tmp);
}
pos = 0;
}
- else
- {
+ else {
tmp[pos] = c;
- pos ++;
+ pos++;
}
}
fclose(file);
@@ -402,8 +398,7 @@ protected: mir_sntprintf(filename, SIZEOF(filename), _T("%s\\%s.cdic"), userPath, language);
FILE *file = _tfopen(filename, _T("ab"));
- if (file != NULL)
- {
+ if (file != NULL) {
char tmp[1024];
toHunspell(tmp, word, SIZEOF(tmp));
fprintf(file, "%s\n", tmp);
@@ -430,7 +425,7 @@ protected: TCHAR* fromHunspell(const char *hunspellWord)
{
int len = MultiByteToWideChar(codePage, 0, hunspellWord, -1, NULL, 0);
- WCHAR *ret = (WCHAR *) malloc((len + 1) * sizeof(WCHAR));
+ WCHAR *ret = (WCHAR *)malloc((len + 1) * sizeof(WCHAR));
MultiByteToWideChar(codePage, 0, hunspellWord, -1, ret, len + 1);
return ret;
}
@@ -439,7 +434,7 @@ protected: {
if (hunspellWord == NULL)
return NULL;
-
+
TCHAR *ret = fromHunspell(hunspellWord);
free(hunspellWord);
return ret;
@@ -480,28 +475,24 @@ public: int len2 = (s2 == NULL ? 0 : lstrlen(s2));
TCHAR *ret;
- if (len1 > 0 && len2 > 0)
- {
- ret = (TCHAR *) malloc(sizeof(TCHAR) * (len1 + len2 + 1));
- lstrcpyn(ret, s1, len1+1);
- lstrcpyn(&ret[len1], s2, len2+1);
+ if (len1 > 0 && len2 > 0) {
+ ret = (TCHAR *)malloc(sizeof(TCHAR) * (len1 + len2 + 1));
+ lstrcpyn(ret, s1, len1 + 1);
+ lstrcpyn(&ret[len1], s2, len2 + 1);
FREE(s1);
FREE(s2);
}
- else if (len1 > 0)
- {
+ else if (len1 > 0) {
ret = s1;
FREE(s2);
}
- else if (len2 > 0)
- {
+ else if (len2 > 0) {
ret = s2;
FREE(s1);
}
- else
- {
- ret = (TCHAR *) malloc(sizeof(TCHAR));
+ else {
+ ret = (TCHAR *)malloc(sizeof(TCHAR));
ret[0] = 0;
FREE(s1);
@@ -510,11 +501,9 @@ public: // Remove duplicated chars
int last = lstrlen(ret) - 1;
- for(int i = 0; i <= last; i++)
- {
+ for (int i = 0; i <= last; i++) {
TCHAR c = ret[i];
- for(int j = last; j > i; j--)
- {
+ for (int j = last; j > i; j--) {
if (c != ret[j])
continue;
if (j != last)
@@ -544,27 +533,23 @@ public: const char *dic_enc = hunspell->get_dic_encoding();
TCHAR *hwordchars;
- if (strcmp(dic_enc, "UTF-8") == 0)
- {
+ if (strcmp(dic_enc, "UTF-8") == 0) {
codePage = CP_UTF8;
int wcs_len;
- hwordchars = fromHunspell((char *) hunspell->get_wordchars_utf16(&wcs_len));
+ hwordchars = fromHunspell((char *)hunspell->get_wordchars_utf16(&wcs_len));
}
- else
- {
- for (int i = 0; i < SIZEOF(codepages); i++)
- {
- if (_strcmpi(codepages[i].name, dic_enc) == 0)
- {
+ else {
+ for (int i = 0; i < SIZEOF(codepages); i++) {
+ if (_strcmpi(codepages[i].name, dic_enc) == 0) {
if (IsValidCodePage(codepages[i].codepage))
codePage = codepages[i].codepage;
break;
}
}
-
+
hwordchars = fromHunspell(hunspell->get_wordchars());
}
@@ -578,7 +563,7 @@ public: int count = hunspell->suggest(&words, "asdf");
for (int i = 0; i < count; i++)
free(words[i]);
- if (words != NULL)
+ if (words != NULL)
free(words);
loadCustomDict();
@@ -604,7 +589,7 @@ public: // Return a list of suggestions to a word
virtual Suggestions suggest(const TCHAR * word)
{
- Suggestions ret = {0};
+ Suggestions ret = { 0 };
load();
if (loaded != LANGUAGE_LOADED)
@@ -616,12 +601,10 @@ public: char ** words = NULL;
ret.count = hunspell->suggest(&words, hunspell_word);
- if (ret.count > 0)
- {
+ if (ret.count > 0) {
// Oki, lets make our array
- ret.words = (TCHAR **) malloc(ret.count * sizeof(TCHAR *));
- for (unsigned i = 0; i < ret.count; i++)
- {
+ ret.words = (TCHAR **)malloc(ret.count * sizeof(TCHAR *));
+ for (unsigned i = 0; i < ret.count; i++) {
ret.words[i] = fromHunspell(words[i]);
free(words[i]);
}
@@ -636,7 +619,7 @@ public: // Return a list of auto suggestions to a word
virtual Suggestions autoSuggest(const TCHAR * word)
{
- Suggestions ret = {0};
+ Suggestions ret = { 0 };
load();
if (loaded != LANGUAGE_LOADED)
@@ -653,9 +636,8 @@ public: // Oki, lets make our array
ret.count = count;
- ret.words = (TCHAR **) malloc(ret.count * sizeof(TCHAR *));
- for (int i = 0; i < count; i++)
- {
+ ret.words = (TCHAR **)malloc(ret.count * sizeof(TCHAR *));
+ for (int i = 0; i < count; i++) {
ret.words[i] = fromHunspell(words[i]);
free(words[i]);
}
@@ -701,14 +683,13 @@ public: if (loaded != LANGUAGE_LOADED)
return TRUE;
- return _tcschr(wordChars, (_TINT) c) != NULL;
+ return _tcschr(wordChars, (_TINT)c) != NULL;
}
// Assert that all needed data is loaded
- virtual void load()
+ virtual void load()
{
- if (loaded == LANGUAGE_NOT_LOADED)
- {
+ if (loaded == LANGUAGE_NOT_LOADED) {
loaded = LANGUAGE_LOADING;
mir_forkthread(LoadThread, this);
}
@@ -726,7 +707,7 @@ public: addWordInternal(word);
appendToCustomDict(word);
}
-
+
// Add a word to the list of ignored words
virtual void ignoreWord(const TCHAR * word)
{
@@ -736,7 +717,7 @@ public: void LoadThread(LPVOID hd)
{
- HunspellDictionary *dict = (HunspellDictionary *) hd;
+ HunspellDictionary *dict = (HunspellDictionary *)hd;
dict->loadThread();
}
@@ -749,7 +730,7 @@ LIST<Dictionary> *tmp_dicts; BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString)
{
TCHAR *stopped = NULL;
- USHORT langID = (USHORT) _tcstol(lpLocaleString, &stopped, 16);
+ USHORT langID = (USHORT)_tcstol(lpLocaleString, &stopped, 16);
TCHAR ini[32];
TCHAR end[32];
@@ -759,11 +740,9 @@ BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) TCHAR name[64];
mir_sntprintf(name, SIZEOF(name), _T("%s_%s"), ini, end);
- for(int i = 0; i < tmp_dicts->getCount(); i++)
- {
+ for (int i = 0; i < tmp_dicts->getCount(); i++) {
Dictionary *dict = (*tmp_dicts)[i];
- if (lstrcmpi(dict->language, name) == 0)
- {
+ if (lstrcmpi(dict->language, name) == 0) {
GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGLANGUAGE, dict->english_name, SIZEOF(dict->english_name));
GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLANGUAGE, dict->localized_name, SIZEOF(dict->localized_name));
@@ -771,8 +750,7 @@ BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SLOCALIZEDLANGUAGENAME, dict->localized_name, SIZEOF(dict->localized_name));
if (dict->localized_name[0] == 0)
GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SNATIVEDISPLAYNAME, dict->localized_name, SIZEOF(dict->localized_name));
- if (dict->localized_name[0] == 0 && dict->english_name[0] != 0)
- {
+ if (dict->localized_name[0] == 0 && dict->english_name[0] != 0) {
TCHAR country[1024];
GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SENGCOUNTRY, country, SIZEOF(country));
@@ -785,8 +763,7 @@ BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) lstrcpyn(dict->localized_name, TranslateTS(name), SIZEOF(dict->localized_name));
}
- if (dict->localized_name[0] != 0)
- {
+ if (dict->localized_name[0] != 0) {
mir_sntprintf(dict->full_name, SIZEOF(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language);
}
break;
@@ -802,40 +779,32 @@ void GetDictsInfo(LIST<Dictionary> &dicts) EnumSystemLocales(EnumLocalesProc, LCID_SUPPORTED);
// Try to get name from DB
- for(int i = 0; i < dicts.getCount(); i++)
- {
+ for (int i = 0; i < dicts.getCount(); i++) {
Dictionary *dict = dicts[i];
-
- if (dict->full_name[0] == _T('\0'))
- {
+
+ if (dict->full_name[0] == _T('\0')) {
DBVARIANT dbv;
char lang[128];
WideCharToMultiByte(CP_ACP, 0, dict->language, -1, lang, sizeof(lang), NULL, NULL);
- if (!db_get_ts(NULL, MODULE_NAME, lang, &dbv))
- {
+ if (!db_get_ts(NULL, MODULE_NAME, lang, &dbv)) {
lstrcpyn(dict->localized_name, dbv.ptszVal, SIZEOF(dict->localized_name));
db_free(&dbv);
}
- if (dict->localized_name[0] == _T('\0'))
- {
- for(size_t j = 0; j < SIZEOF(aditionalLanguages); j++)
- {
- if (!lstrcmp(aditionalLanguages[j].language, dict->language))
- {
+ if (dict->localized_name[0] == _T('\0')) {
+ for (size_t j = 0; j < SIZEOF(aditionalLanguages); j++) {
+ if (!lstrcmp(aditionalLanguages[j].language, dict->language)) {
lstrcpyn(dict->localized_name, TranslateTS(aditionalLanguages[j].localized_name), SIZEOF(dict->localized_name));
break;
}
}
}
- if (dict->localized_name[0] != _T('\0'))
- {
+ if (dict->localized_name[0] != _T('\0')) {
mir_sntprintf(dict->full_name, SIZEOF(dict->full_name), _T("%s [%s]"), dict->localized_name, dict->language);
}
- else
- {
+ else {
lstrcpyn(dict->full_name, dict->language, SIZEOF(dict->full_name));
}
}
@@ -851,12 +820,10 @@ void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, TCHAR *path, TCH BOOL found = FALSE;
- WIN32_FIND_DATA ffd = {0};
+ WIN32_FIND_DATA ffd = { 0 };
HANDLE hFFD = FindFirstFile(file, &ffd);
- if (hFFD != INVALID_HANDLE_VALUE)
- {
- do
- {
+ if (hFFD != INVALID_HANDLE_VALUE) {
+ do {
mir_sntprintf(file, SIZEOF(file), _T("%s\\%s"), path, ffd.cFileName);
// Check .dic
@@ -870,29 +837,28 @@ void GetHunspellDictionariesFromFolder(LIST<Dictionary> &dicts, TCHAR *path, TCH if (attrib == 0xFFFFFFFF || (attrib & FILE_ATTRIBUTE_DIRECTORY))
continue;
- ffd.cFileName[lstrlen(ffd.cFileName)-4] = _T('\0');
+ ffd.cFileName[lstrlen(ffd.cFileName) - 4] = _T('\0');
TCHAR *lang = ffd.cFileName;
// Replace - for _
- for(int i = 0; i < lstrlen(lang); i++)
+ for (int i = 0; i < lstrlen(lang); i++)
if (lang[i] == _T('-'))
lang[i] = _T('_');
// Check if dict is new
bool exists = false;
- for(int i = 0; i < dicts.getCount() && !exists; i++)
+ for (int i = 0; i < dicts.getCount() && !exists; i++)
if (lstrcmp(dicts[i]->language, lang) == 0)
exists = true;
- if (!exists)
- {
+ if (!exists) {
found = TRUE;
file[lstrlen(file) - 4] = _T('\0');
dicts.insert(new HunspellDictionary(lang, file, user_path, source));
}
}
- while(FindNextFile(hFFD, &ffd));
+ while (FindNextFile(hFFD, &ffd));
FindClose(hFFD);
}
@@ -905,44 +871,36 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_pa // Get miranda folder dicts
GetHunspellDictionariesFromFolder(dicts, path, user_path, NULL);
- if (opts.use_other_apps_dicts)
- {
+ if (opts.use_other_apps_dicts) {
// Get other apps dicts
- for (int i = 0; i < SIZEOF(otherHunspellApps); i++)
- {
+ for (int i = 0; i < SIZEOF(otherHunspellApps); i++) {
TCHAR key[1024];
mir_sntprintf(key, SIZEOF(key), APPPATH, otherHunspellApps[i].key);
HKEY hKey = 0;
LONG lResult = 0;
- if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE, &hKey))
- {
+ if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE, &hKey)) {
DWORD size = SIZEOF(key);
lResult = RegQueryValueEx(hKey, _T("Path"), NULL, NULL, (LPBYTE)key, &size);
RegCloseKey(hKey);
}
- else
- {
+ else {
// Not found in installed apps - Try MUICache
lResult = RegOpenKeyEx(HKEY_CURRENT_USER, MUICACHE, 0, KEY_QUERY_VALUE, &hKey);
- if (ERROR_SUCCESS == lResult)
- {
+ if (ERROR_SUCCESS == lResult) {
DWORD numValues;
- if (ERROR_SUCCESS != RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &numValues, NULL, NULL, NULL, NULL))
+ if (ERROR_SUCCESS != RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, &numValues, NULL, NULL, NULL, NULL))
numValues = 0;
lResult = ERROR_NO_MORE_ITEMS;
- for (DWORD local = 0; local < numValues; local++)
- {
+ for (DWORD local = 0; local < numValues; local++) {
DWORD cchValue = SIZEOF(key);
- if (ERROR_SUCCESS != RegEnumValue(hKey, local, key, &cchValue, NULL, NULL, NULL, NULL))
+ if (ERROR_SUCCESS != RegEnumValue(hKey, local, key, &cchValue, NULL, NULL, NULL, NULL))
break;
key[cchValue] = 0;
TCHAR *pos;
- if (pos = _tcsrchr(key, _T('\\')))
- {
- if (!lstrcmpi(&pos[1], otherHunspellApps[i].key))
- {
+ if (pos = _tcsrchr(key, _T('\\'))) {
+ if (!lstrcmpi(&pos[1], otherHunspellApps[i].key)) {
pos[0] = 0;
lResult = ERROR_SUCCESS;
break;
@@ -950,31 +908,27 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, TCHAR *path, TCHAR *user_pa }
}
RegCloseKey(hKey);
- }
+ }
}
- if (ERROR_SUCCESS == lResult)
- {
+ if (ERROR_SUCCESS == lResult) {
TCHAR folder[1024];
mir_sntprintf(folder, SIZEOF(folder), _T("%s\\Dictionaries"), key);
GetHunspellDictionariesFromFolder(languages, folder, user_path, otherHunspellApps[i].name);
- }
+ }
}
}
GetDictsInfo(dicts);
// Yeah, yeah, yeah, I know, but this is the easiest way...
- SortedList *sl = (SortedList *) &dicts;
+ SortedList *sl = (SortedList *)&dicts;
// Sort dicts
- for(int i = 0; i < dicts.getCount(); i++)
- {
- for(int j = i + 1; j < dicts.getCount(); j++)
- {
- if (lstrcmp(dicts[i]->full_name, dicts[j]->full_name) > 0)
- {
+ for (int i = 0; i < dicts.getCount(); i++) {
+ for (int j = i + 1; j < dicts.getCount(); j++) {
+ if (lstrcmp(dicts[i]->full_name, dicts[j]->full_name) > 0) {
Dictionary *dict = dicts[i];
sl->items[i] = dicts[j];
sl->items[j] = dict;
@@ -1002,9 +956,8 @@ Dictionary::~Dictionary() void FreeSuggestions(Suggestions &suggestions)
{
for (size_t i = 0; i < suggestions.count; i++)
- {
free(suggestions.words[i]);
- }
+
free(suggestions.words);
suggestions.words = NULL;
diff --git a/plugins/SpellChecker/src/options.cpp b/plugins/SpellChecker/src/options.cpp index 748e80163e..8ae164d222 100644 --- a/plugins/SpellChecker/src/options.cpp +++ b/plugins/SpellChecker/src/options.cpp @@ -197,7 +197,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP case WM_COMMAND:
if (LOWORD(wParam) == IDC_GETMORE)
- CallService(MS_UTILS_OPENURL, 1, (LPARAM) "http://wiki.services.openoffice.org/wiki/Dictionaries");
+ CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://wiki.services.openoffice.org/wiki/Dictionaries");
if (LOWORD(wParam) == IDC_DEF_LANG && (HIWORD(wParam) == CBN_SELCHANGE && (HWND)lParam == GetFocus())) {
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp index d9a73daeec..6661274c21 100644 --- a/plugins/SpellChecker/src/utils.cpp +++ b/plugins/SpellChecker/src/utils.cpp @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. #include "commons.h" -typedef void (*FoundWrongWordCallback)(TCHAR *word, CHARRANGE pos, void *param); +typedef void(*FoundWrongWordCallback)(TCHAR *word, CHARRANGE pos, void *param); typedef map<HWND, Dialog *> DialogMapType; DialogMapType dialogs; @@ -34,7 +34,7 @@ void SetUnderline(Dialog *dlg, int pos_start, int pos_end) cf.dwMask = CFM_UNDERLINE | CFM_UNDERLINETYPE; cf.dwEffects = CFE_UNDERLINE; cf.bUnderlineType = ((opts.underline_type + CFU_UNDERLINEDOUBLE) | 0x50); - dlg->re->SendMessage(EM_SETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM)&cf); + dlg->re->SendMessage(EM_SETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&cf); dlg->markedSomeWord = TRUE; } @@ -42,20 +42,20 @@ void SetUnderline(Dialog *dlg, int pos_start, int pos_end) BOOL IsMyUnderline(const CHARFORMAT2 &cf) { return (cf.dwEffects & CFE_UNDERLINE) - && (cf.bUnderlineType & 0x0F) >= CFU_UNDERLINEDOUBLE - && (cf.bUnderlineType & 0x0F) <= CFU_UNDERLINETHICK - && (cf.bUnderlineType & ~0x0F) == 0x50; + && (cf.bUnderlineType & 0x0F) >= CFU_UNDERLINEDOUBLE + && (cf.bUnderlineType & 0x0F) <= CFU_UNDERLINETHICK + && (cf.bUnderlineType & ~0x0F) == 0x50; } void SetNoUnderline(RichEdit *re, int pos_start, int pos_end) { if (opts.handle_underscore) { - for(int i = pos_start; i <= pos_end; i++) { - re->SetSel(i, min(i+1, pos_end)); + for (int i = pos_start; i <= pos_end; i++) { + re->SetSel(i, min(i + 1, pos_end)); CHARFORMAT2 cf; cf.cbSize = sizeof(CHARFORMAT2); - re->SendMessage(EM_GETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM)&cf); + re->SendMessage(EM_GETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&cf); BOOL mine = IsMyUnderline(cf); if (mine) { @@ -63,7 +63,7 @@ void SetNoUnderline(RichEdit *re, int pos_start, int pos_end) cf.dwMask = CFM_UNDERLINE | CFM_UNDERLINETYPE; cf.dwEffects = 0; cf.bUnderlineType = CFU_UNDERLINE; - re->SendMessage(EM_SETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM)&cf); + re->SendMessage(EM_SETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&cf); } } } @@ -75,7 +75,7 @@ void SetNoUnderline(RichEdit *re, int pos_start, int pos_end) cf.dwMask = CFM_UNDERLINE | CFM_UNDERLINETYPE; cf.dwEffects = 0; cf.bUnderlineType = CFU_UNDERLINE; - re->SendMessage(EM_SETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM)&cf); + re->SendMessage(EM_SETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&cf); } } @@ -158,10 +158,10 @@ public: virtual ~TextParser() {} /// @return true when finished an word - virtual bool feed(int pos, TCHAR c) =0; - virtual int getFirstCharPos() =0; - virtual void reset() =0; - virtual void deal(const TCHAR *text, bool *mark, bool *replace, TCHAR **replacement) =0; + virtual bool feed(int pos, TCHAR c) = 0; + virtual int getFirstCharPos() = 0; + virtual void reset() = 0; + virtual void deal(const TCHAR *text, bool *mark, bool *replace, TCHAR **replacement) = 0; }; class SpellParser : public TextParser @@ -270,8 +270,8 @@ public: }; int CheckTextLine(Dialog *dlg, int line, TextParser *parser, - BOOL ignore_upper, BOOL ignore_with_numbers, BOOL test_urls, - const CHARRANGE &ignored, FoundWrongWordCallback callback, void *param) + BOOL ignore_upper, BOOL ignore_with_numbers, BOOL test_urls, + const CHARRANGE &ignored, FoundWrongWordCallback callback, void *param) { int errors = 0; TCHAR text[1024]; @@ -296,7 +296,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, parser->reset(); BOOL feed = FALSE; - for(int j = pos; !feed && j <= url_end; j++) + for (int j = pos; !feed && j <= url_end; j++) feed = parser->feed(j, text[j]); if (feed || parser->getFirstCharPos() != pos) @@ -316,7 +316,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, BOOL feed = parser->feed(pos, c); if (!feed) { - if (pos >= len-1) + if (pos >= len - 1) pos = len; // To check the last block else continue; @@ -338,7 +338,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, if (ignore_upper) { BOOL upper = TRUE; - for(int i = last_pos; i < pos && upper; i++) + for (int i = last_pos; i < pos && upper; i++) upper = !IsCharLower(text[i]); if (upper) continue; @@ -346,7 +346,7 @@ int CheckTextLine(Dialog *dlg, int line, TextParser *parser, if (ignore_with_numbers) { BOOL hasNumbers = FALSE; - for(int i = last_pos; i < pos && !hasNumbers; i++) + for (int i = last_pos; i < pos && !hasNumbers; i++) hasNumbers = IsNumber(text[i]); if (hasNumbers) continue; @@ -413,14 +413,14 @@ int CheckText(Dialog *dlg, BOOL check_all, FoundWrongWordCallback callback = NUL SetNoUnderline(dlg->re, first_char, first_char + dlg->re->GetLineLength(line)); - if (opts.auto_replace_user) + if (opts.auto_replace_user) errors += CheckTextLine(dlg, line, &AutoReplaceParser(dlg->lang->autoReplace), - FALSE, FALSE, TRUE, - cur_sel, callback, param); + FALSE, FALSE, TRUE, + cur_sel, callback, param); errors += CheckTextLine(dlg, line, &SpellParser(dlg->lang), - opts.ignore_uppercase, opts.ignore_with_numbers, FALSE, - cur_sel, callback, param); + opts.ignore_uppercase, opts.ignore_with_numbers, FALSE, + cur_sel, callback, param); } } @@ -435,7 +435,7 @@ int CheckText(Dialog *dlg, BOOL check_all, FoundWrongWordCallback callback = NUL void ToLocaleID(TCHAR *szKLName, size_t size) { TCHAR *stopped = NULL; - USHORT langID = (USHORT) _tcstol(szKLName, &stopped, 16); + USHORT langID = (USHORT)_tcstol(szKLName, &stopped, 16); TCHAR ini[32], end[32]; GetLocaleInfo(MAKELCID(langID, 0), LOCALE_SISO639LANGNAME, ini, SIZEOF(ini)); @@ -450,7 +450,7 @@ void LoadDictFromKbdl(Dialog *dlg) // Use default input language HKL hkl = GetKeyboardLayout(0); - mir_sntprintf(szKLName, SIZEOF(szKLName), _T("%x"), (int) LOWORD(hkl)); + mir_sntprintf(szKLName, SIZEOF(szKLName), _T("%x"), (int)LOWORD(hkl)); ToLocaleID(szKLName, SIZEOF(szKLName)); int d = GetClosestLanguage(szKLName); @@ -502,8 +502,8 @@ LRESULT CALLBACK OwnerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int errors = TimerCheck(dlg, TRUE); if (errors > 0) { TCHAR text[500]; - mir_sntprintf(text,SIZEOF(text),TranslateT("There are %d spelling errors. Are you sure you want to send this message?"),errors); - if (MessageBox(hwnd,text,TranslateT("Spell Checker"), MB_ICONQUESTION | MB_YESNO) == IDNO) + mir_sntprintf(text, SIZEOF(text), TranslateT("There are %d spelling errors. Are you sure you want to send this message?"), errors); + if (MessageBox(hwnd, text, TranslateT("Spell Checker"), MB_ICONQUESTION | MB_YESNO) == IDNO) return TRUE; } } @@ -553,13 +553,13 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return -1; // Hotkey support - MSG msgData = {0}; + MSG msgData = { 0 }; msgData.hwnd = hwnd; msgData.message = msg; msgData.wParam = wParam; msgData.lParam = lParam; - int action = CallService(MS_HOTKEY_CHECK, (WPARAM) &msgData, (LPARAM) "Spell Checker"); + int action = CallService(MS_HOTKEY_CHECK, (WPARAM)&msgData, (LPARAM)"Spell Checker"); if (action == HOTKEY_ACTION_TOGGLE) { ToggleEnabled(dlg); return 1; @@ -569,7 +569,7 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if ((dlgit = dialogs.find(hwnd)) == dialogs.end()) return ret; - switch(msg) { + switch (msg) { case WM_KEYDOWN: if (wParam != VK_DELETE) break; @@ -581,11 +581,11 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (lParam & (1 << 28)) // ALT key break; - if ( GetKeyState(VK_CONTROL) & 0x8000) // CTRL key + if (GetKeyState(VK_CONTROL) & 0x8000) // CTRL key break; { - TCHAR c = (TCHAR) wParam; + TCHAR c = (TCHAR)wParam; BOOL deleting = (c == VK_BACK || c == VK_DELETE); // Need to do that to avoid changing the word while typing @@ -610,9 +610,9 @@ LRESULT CALLBACK EditProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) // Remove underline of current word CHARFORMAT2 cf; cf.cbSize = sizeof(CHARFORMAT2); - dlg->re->SendMessage(EM_GETCHARFORMAT, (WPARAM) SCF_SELECTION, (LPARAM)&cf); + dlg->re->SendMessage(EM_GETCHARFORMAT, (WPARAM)SCF_SELECTION, (LPARAM)&cf); - if ( IsMyUnderline(cf)) { + if (IsMyUnderline(cf)) { dlg->re->Stop(); CHARRANGE sel = dlg->re->GetSel(); @@ -717,10 +717,10 @@ int GetClosestLanguage(TCHAR *lang_name) void GetUserProtoLanguageSetting(Dialog *dlg, MCONTACT hContact, char *group, char *setting, BOOL isProtocol = TRUE) { - DBVARIANT dbv = {0}; + DBVARIANT dbv = { 0 }; dbv.type = DBVT_TCHAR; - DBCONTACTGETSETTING cgs = {0}; + DBCONTACTGETSETTING cgs = { 0 }; cgs.szModule = group; cgs.szSetting = setting; cgs.pValue = &dbv; @@ -729,7 +729,7 @@ void GetUserProtoLanguageSetting(Dialog *dlg, MCONTACT hContact, char *group, ch int caps = (isProtocol ? CallProtoService(group, PS_GETCAPS, PFLAGNUM_4, 0) : 0); if (caps & PF4_INFOSETTINGSVC) - rc = CallProtoService(group, PS_GETINFOSETTING, hContact, (LPARAM) &cgs); + rc = CallProtoService(group, PS_GETINFOSETTING, hContact, (LPARAM)&cgs); else { rc = CallService(MS_DB_CONTACT_GETSETTING_STR_EX, hContact, (LPARAM)&cgs); if (rc == CALLSERVICE_NOTFOUND) @@ -742,9 +742,8 @@ void GetUserProtoLanguageSetting(Dialog *dlg, MCONTACT hContact, char *group, ch for (int i = 0; i < languages.getCount(); i++) { Dictionary *dict = languages[i]; if (lstrcmpi(dict->localized_name, lang) == 0 - || lstrcmpi(dict->english_name, lang) == 0 - || lstrcmpi(dict->language, lang) == 0) - { + || lstrcmpi(dict->english_name, lang) == 0 + || lstrcmpi(dict->language, lang) == 0) { lstrcpyn(dlg->lang_name, dict->language, SIZEOF(dlg->lang_name)); break; } @@ -782,12 +781,12 @@ void GetUserLanguageSetting(Dialog *dlg, char *setting) void GetContactLanguage(Dialog *dlg) { - DBVARIANT dbv = {0}; + DBVARIANT dbv = { 0 }; dlg->lang_name[0] = _T('\0'); if (dlg->hContact == NULL) { - if ( !db_get_ts(NULL, MODULE_NAME, dlg->name, &dbv)) { + if (!db_get_ts(NULL, MODULE_NAME, dlg->name, &dbv)) { lstrcpyn(dlg->lang_name, dbv.ptszVal, SIZEOF(dlg->lang_name)); db_free(&dbv); } @@ -867,26 +866,13 @@ void ModifyIcon(Dialog *dlg) INT_PTR AddContactTextBoxService(WPARAM wParam, LPARAM lParam) { - SPELLCHECKER_ITEM *sci = (SPELLCHECKER_ITEM *) wParam; + SPELLCHECKER_ITEM *sci = (SPELLCHECKER_ITEM *)wParam; if (sci == NULL || sci->cbSize != sizeof(SPELLCHECKER_ITEM)) return -1; return AddContactTextBox(sci->hContact, sci->hwnd, sci->window_name, FALSE, NULL); } -void NotifyWrongSRMM() -{ - static BOOL notified = FALSE; - if (notified) - return; - - MessageBox(NULL, - TranslateT("Your message window does not support SpellChecker Plugin.\nIf you use SRMM, TabSRMM or Scriver, please update them to the latest version,\notherwise ask the author of your message window plugin to add support for Spell Checker."), - TranslateT("Spell Checker"), MB_ICONERROR | MB_OK); - - notified = TRUE; -} - int AddContactTextBox(MCONTACT hContact, HWND hwnd, char *name, BOOL srmm, HWND hwndOwner) { if (languages.getCount() <= 0) @@ -894,17 +880,13 @@ int AddContactTextBox(MCONTACT hContact, HWND hwnd, char *name, BOOL srmm, HWND if (dialogs.find(hwnd) == dialogs.end()) { // Fill dialog data - Dialog *dlg = (Dialog *) malloc(sizeof(Dialog)); + Dialog *dlg = (Dialog *)malloc(sizeof(Dialog)); ZeroMemory(dlg, sizeof(Dialog)); dlg->re = new RichEdit(hwnd); if (!dlg->re->IsValid()) { delete dlg->re; free(dlg); - - if (srmm) - NotifyWrongSRMM(); - return 0; } @@ -943,16 +925,16 @@ int AddContactTextBox(MCONTACT hContact, HWND hwnd, char *name, BOOL srmm, HWND void FreePopupData(Dialog *dlg) { - DESTROY_MENY(dlg->hLanguageSubMenu) - DESTROY_MENY(dlg->hWrongWordsSubMenu) + DESTROY_MENY(dlg->hLanguageSubMenu); + DESTROY_MENY(dlg->hWrongWordsSubMenu); if (dlg->wrong_words != NULL) { for (unsigned i = 0; i < dlg->wrong_words->size(); i++) { - FREE((*dlg->wrong_words)[i].word) + FREE((*dlg->wrong_words)[i].word); - DESTROY_MENY((*dlg->wrong_words)[i].hMeSubMenu) - DESTROY_MENY((*dlg->wrong_words)[i].hCorrectSubMenu) - DESTROY_MENY((*dlg->wrong_words)[i].hReplaceSubMenu) + DESTROY_MENY((*dlg->wrong_words)[i].hMeSubMenu); + DESTROY_MENY((*dlg->wrong_words)[i].hCorrectSubMenu); + DESTROY_MENY((*dlg->wrong_words)[i].hReplaceSubMenu); FreeSuggestions((*dlg->wrong_words)[i].suggestions); } @@ -964,7 +946,7 @@ void FreePopupData(Dialog *dlg) INT_PTR RemoveContactTextBoxService(WPARAM wParam, LPARAM lParam) { - HWND hwnd = (HWND) wParam; + HWND hwnd = (HWND)wParam; if (hwnd == NULL) return -1; @@ -1005,12 +987,12 @@ BOOL GetWordCharRange(Dialog *dlg, CHARRANGE &sel, TCHAR *text, size_t text_len, // Find the word sel.cpMin--; while (sel.cpMin >= first_char && (dlg->lang->isWordChar(text[sel.cpMin - first_char]) - || IsNumber(text[sel.cpMin - first_char]))) + || IsNumber(text[sel.cpMin - first_char]))) sel.cpMin--; sel.cpMin++; while (text[sel.cpMax - first_char] != _T('\0') && (dlg->lang->isWordChar(text[sel.cpMax - first_char]) - || IsNumber(text[sel.cpMax - first_char]))) + || IsNumber(text[sel.cpMax - first_char]))) sel.cpMax++; // Has a word? @@ -1020,7 +1002,7 @@ BOOL GetWordCharRange(Dialog *dlg, CHARRANGE &sel, TCHAR *text, size_t text_len, // See if it has only '-'s BOOL has_valid_char = FALSE; for (int i = sel.cpMin; i < sel.cpMax && !has_valid_char; i++) - has_valid_char = ( text[i - first_char] != _T('-')); + has_valid_char = (text[i - first_char] != _T('-')); return has_valid_char; } @@ -1049,7 +1031,7 @@ TCHAR *GetWordUnderPoint(Dialog *dlg, POINT pt, CHARRANGE &sel) void AppendSubmenu(HMENU hMenu, HMENU hSubMenu, TCHAR *name) { - MENUITEMINFO mii = {0}; + MENUITEMINFO mii = { sizeof(mii) }; mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_SUBMENU | MIIM_TYPE; mii.fType = MFT_STRING; @@ -1062,10 +1044,9 @@ void AppendSubmenu(HMENU hMenu, HMENU hSubMenu, TCHAR *name) void AppendMenuItem(HMENU hMenu, int id, TCHAR *name, HICON hIcon, BOOL checked) { ICONINFO iconInfo; - GetIconInfo(hIcon, & iconInfo); + GetIconInfo(hIcon, &iconInfo); - MENUITEMINFO mii = {0}; - mii.cbSize = sizeof(MENUITEMINFO); + MENUITEMINFO mii = { sizeof(mii) }; mii.fMask = MIIM_CHECKMARKS | MIIM_TYPE | MIIM_STATE; mii.fType = MFT_STRING; mii.fState = (checked ? MFS_CHECKED : 0); @@ -1109,7 +1090,7 @@ void AddMenuForWord(Dialog *dlg, TCHAR *word, CHARRANGE &pos, HMENU hMenu, BOOL InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION, base + AUTOREPLACE_MENU_ID_BASE + suggestions.count, TranslateT("Other...")); if (suggestions.count > 0) { InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); - for (int i = (int)suggestions.count-1; i >= 0; i--) + for (int i = (int)suggestions.count - 1; i >= 0; i--) InsertMenu(data.hReplaceSubMenu, 0, MF_BYPOSITION, base + AUTOREPLACE_MENU_ID_BASE + i, suggestions.words[i]); } @@ -1142,16 +1123,17 @@ void AddMenuForWord(Dialog *dlg, TCHAR *word, CHARRANGE &pos, HMENU hMenu, BOOL } } -struct FoundWrongWordParam { +struct FoundWrongWordParam +{ Dialog *dlg; int count; }; void FoundWrongWord(TCHAR *word, CHARRANGE pos, void *param) { - FoundWrongWordParam *p = (FoundWrongWordParam*) param; + FoundWrongWordParam *p = (FoundWrongWordParam*)param; - p->count ++; + p->count++; AddMenuForWord(p->dlg, _tcsdup(word), pos, p->dlg->hWrongWordsSubMenu, TRUE, WORD_MENU_ID_BASE * p->count); } @@ -1179,7 +1161,7 @@ void AddItemsToMenu(Dialog *dlg, HMENU hMenu, POINT pt, HWND hwndOwner) // First add languages for (int i = 0; i < languages.getCount(); i++) AppendMenu(dlg->hLanguageSubMenu, MF_STRING | (languages[i] == dlg->lang ? MF_CHECKED : 0), - LANGUAGE_MENU_ID_BASE + i, languages[i]->full_name); + LANGUAGE_MENU_ID_BASE + i, languages[i]->full_name); AppendSubmenu(hMenu, dlg->hLanguageSubMenu, TranslateT("Language")); } @@ -1211,15 +1193,15 @@ void AddItemsToMenu(Dialog *dlg, HMENU hMenu, POINT pt, HWND hwndOwner) static void AddWordToDictCallback(BOOL canceled, Dictionary *dict, - const TCHAR *find, const TCHAR *replace, BOOL useVariables, - const TCHAR *original_find, void *param) + const TCHAR *find, const TCHAR *replace, BOOL useVariables, + const TCHAR *original_find, void *param) { if (canceled) return; dict->autoReplace->add(find, replace, useVariables); - HWND hwndParent = (HWND) param; + HWND hwndParent = (HWND)param; if (hwndParent != NULL) PostMessage(hwndParent, WMU_DICT_CHANGED, 0, 0); } @@ -1233,15 +1215,15 @@ BOOL HandleMenuSelection(Dialog *dlg, POINT pt, unsigned selection) ToggleEnabled(dlg); ret = TRUE; } - else if (selection >= LANGUAGE_MENU_ID_BASE && selection < LANGUAGE_MENU_ID_BASE + (unsigned) languages.getCount()) { + else if (selection >= LANGUAGE_MENU_ID_BASE && selection < LANGUAGE_MENU_ID_BASE + (unsigned)languages.getCount()) { SetNoUnderline(dlg); if (dlg->hContact == NULL) db_set_ts(NULL, MODULE_NAME, dlg->name, - languages[selection - LANGUAGE_MENU_ID_BASE]->language); + languages[selection - LANGUAGE_MENU_ID_BASE]->language); else db_set_ts(dlg->hContact, MODULE_NAME, "TalkLanguage", - languages[selection - LANGUAGE_MENU_ID_BASE]->language); + languages[selection - LANGUAGE_MENU_ID_BASE]->language); GetContactLanguage(dlg); @@ -1251,11 +1233,10 @@ BOOL HandleMenuSelection(Dialog *dlg, POINT pt, unsigned selection) ret = TRUE; } else if (selection > 0 && dlg->wrong_words != NULL - && selection >= WORD_MENU_ID_BASE - && selection < (dlg->wrong_words->size() + 1) * WORD_MENU_ID_BASE) - { + && selection >= WORD_MENU_ID_BASE + && selection < (dlg->wrong_words->size() + 1) * WORD_MENU_ID_BASE) { int pos = selection / WORD_MENU_ID_BASE; - selection -= pos * WORD_MENU_ID_BASE; + selection -= pos * WORD_MENU_ID_BASE; pos--; // 0 based WrongWordPopupMenuData &data = (*dlg->wrong_words)[pos]; @@ -1276,8 +1257,8 @@ BOOL HandleMenuSelection(Dialog *dlg, POINT pt, unsigned selection) selection -= AUTOREPLACE_MENU_ID_BASE; if (selection == data.suggestions.count) { ShowAutoReplaceDialog(dlg->hwnd_owner != NULL ? dlg->hwnd_owner : dlg->hwnd, FALSE, - dlg->lang, data.word, NULL, FALSE, - TRUE, &AddWordToDictCallback, dlg->hwnd); + dlg->lang, data.word, NULL, FALSE, + TRUE, &AddWordToDictCallback, dlg->hwnd); } else { // TODO Assert that text hasn't changed @@ -1301,7 +1282,7 @@ BOOL HandleMenuSelection(Dialog *dlg, POINT pt, unsigned selection) int MsgWindowPopup(WPARAM wParam, LPARAM lParam) { - MessageWindowPopupData *mwpd = (MessageWindowPopupData *) lParam; + MessageWindowPopupData *mwpd = (MessageWindowPopupData *)lParam; if (mwpd == NULL || mwpd->cbSize < sizeof(MessageWindowPopupData) || mwpd->uFlags != MSG_WINDOWPOPUP_INPUT) return 0; @@ -1324,7 +1305,7 @@ int MsgWindowPopup(WPARAM wParam, LPARAM lParam) INT_PTR ShowPopupMenuService(WPARAM wParam, LPARAM lParam) { - SPELLCHECKER_POPUPMENU *scp = (SPELLCHECKER_POPUPMENU *) wParam; + SPELLCHECKER_POPUPMENU *scp = (SPELLCHECKER_POPUPMENU *)wParam; if (scp == NULL || scp->cbSize != sizeof(SPELLCHECKER_POPUPMENU)) return -1; @@ -1341,10 +1322,10 @@ int ShowPopupMenu(HWND hwnd, HMENU hMenu, POINT pt, HWND hwndOwner) if (pt.x == 0xFFFF && pt.y == 0xFFFF) { CHARRANGE sel; - SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM) &sel); + SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel); // Get current cursor pos - SendMessage(hwnd, EM_POSFROMCHAR, (WPARAM)&pt, (LPARAM) sel.cpMax); + SendMessage(hwnd, EM_POSFROMCHAR, (WPARAM)&pt, (LPARAM)sel.cpMax); } else ScreenToClient(hwnd, &pt); @@ -1390,7 +1371,7 @@ int MsgWindowEvent(WPARAM wParam, LPARAM lParam) int IconPressed(WPARAM hContact, LPARAM lParam) { - StatusIconClickData *sicd = (StatusIconClickData *) lParam; + StatusIconClickData *sicd = (StatusIconClickData *)lParam; if (sicd == NULL || strcmp(sicd->szModule, MODULE_NAME) != 0) return 0; @@ -1400,7 +1381,7 @@ int IconPressed(WPARAM hContact, LPARAM lParam) // Find the dialog HWND hwnd = NULL; Dialog *dlg; - for(DialogMapType::iterator it = dialogs.begin(); it != dialogs.end(); it++) { + for (DialogMapType::iterator it = dialogs.begin(); it != dialogs.end(); it++) { dlg = it->second; if (dlg->srmm && dlg->hContact == hContact) { hwnd = it->first; @@ -1408,10 +1389,8 @@ int IconPressed(WPARAM hContact, LPARAM lParam) } } - if (hwnd == NULL) { - NotifyWrongSRMM(); + if (hwnd == NULL) return 0; - } if ((sicd->flags & MBCF_RIGHTBUTTON) == 0) { FreePopupData(dlg); @@ -1428,8 +1407,7 @@ int IconPressed(WPARAM hContact, LPARAM lParam) // First add languages for (int i = 0; i < languages.getCount(); i++) - AppendMenu(hMenu, MF_STRING | (languages[i] == dlg->lang ? MF_CHECKED : 0), - LANGUAGE_MENU_ID_BASE + i, languages[i]->full_name); + AppendMenu(hMenu, MF_STRING | (languages[i] == dlg->lang ? MF_CHECKED : 0), LANGUAGE_MENU_ID_BASE + i, languages[i]->full_name); InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, 0); } @@ -1461,15 +1439,15 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) switch (msg) { case WM_INITMENUPOPUP: { - HMENU hMenu = (HMENU) wParam; + HMENU hMenu = (HMENU)wParam; int count = GetMenuItemCount(hMenu); - for(int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { unsigned id = GetMenuItemID(hMenu, i); - if (id < LANGUAGE_MENU_ID_BASE || id >= LANGUAGE_MENU_ID_BASE + (unsigned) languages.getCount()) + if (id < LANGUAGE_MENU_ID_BASE || id >= LANGUAGE_MENU_ID_BASE + (unsigned)languages.getCount()) continue; - MENUITEMINFO mii = {0}; + MENUITEMINFO mii = { 0 }; mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_STATE; GetMenuItemInfo(hMenu, id, FALSE, &mii); @@ -1483,7 +1461,7 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_DRAWITEM: { LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; - if (lpdis->CtlType != ODT_MENU || lpdis->itemID < LANGUAGE_MENU_ID_BASE || lpdis->itemID >= LANGUAGE_MENU_ID_BASE + (unsigned) languages.getCount()) + if (lpdis->CtlType != ODT_MENU || lpdis->itemID < LANGUAGE_MENU_ID_BASE || lpdis->itemID >= LANGUAGE_MENU_ID_BASE + (unsigned)languages.getCount()) break; int pos = lpdis->itemID - LANGUAGE_MENU_ID_BASE; @@ -1491,9 +1469,9 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) Dictionary *dict = languages[pos]; COLORREF clrfore = SetTextColor(lpdis->hDC, - GetSysColor(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT)); + GetSysColor(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT)); COLORREF clrback = SetBkColor(lpdis->hDC, - GetSysColor(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_MENU)); + GetSysColor(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_MENU)); FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(lpdis->itemState & ODS_SELECTED ? COLOR_HIGHLIGHT : COLOR_MENU)); @@ -1508,7 +1486,7 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) rc.bottom = rc.top + bmpChecked.bmHeight; HDC hdcTemp = CreateCompatibleDC(lpdis->hDC); - HBITMAP oldBmp = (HBITMAP) SelectObject(hdcTemp, hCheckedBmp); + HBITMAP oldBmp = (HBITMAP)SelectObject(hdcTemp, hCheckedBmp); BitBlt(lpdis->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hdcTemp, 0, 0, SRCCOPY); @@ -1542,60 +1520,57 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) // Restore old colors SetTextColor(lpdis->hDC, clrfore); SetBkColor(lpdis->hDC, clrback); - - return TRUE; } + return TRUE; case WM_MEASUREITEM: - { - LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam; - if (lpmis->CtlType != ODT_MENU || lpmis->itemID < LANGUAGE_MENU_ID_BASE || lpmis->itemID >= LANGUAGE_MENU_ID_BASE + (unsigned) languages.getCount()) - break; + LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT)lParam; + if (lpmis->CtlType != ODT_MENU || lpmis->itemID < LANGUAGE_MENU_ID_BASE || lpmis->itemID >= LANGUAGE_MENU_ID_BASE + (unsigned)languages.getCount()) + break; - int pos = lpmis->itemID - LANGUAGE_MENU_ID_BASE; + int pos = lpmis->itemID - LANGUAGE_MENU_ID_BASE; - Dictionary *dict = languages[pos]; + Dictionary *dict = languages[pos]; - HDC hdc = GetDC(hwnd); + HDC hdc = GetDC(hwnd); - NONCLIENTMETRICS info; - ZeroMemory(&info, sizeof(info)); - info.cbSize = sizeof(info); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0); - HFONT hFont = CreateFontIndirect(&info.lfMenuFont); - HFONT hFontOld = (HFONT) SelectObject(hdc, hFont); + NONCLIENTMETRICS info; + ZeroMemory(&info, sizeof(info)); + info.cbSize = sizeof(info); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0); + HFONT hFont = CreateFontIndirect(&info.lfMenuFont); + HFONT hFontOld = (HFONT)SelectObject(hdc, hFont); - RECT rc = { 0, 0, 0xFFFF, 0xFFFF }; + RECT rc = { 0, 0, 0xFFFF, 0xFFFF }; - DrawText(hdc, dict->full_name, lstrlen(dict->full_name), &rc, DT_NOPREFIX | DT_SINGLELINE | DT_LEFT | DT_TOP | DT_CALCRECT); + DrawText(hdc, dict->full_name, lstrlen(dict->full_name), &rc, DT_NOPREFIX | DT_SINGLELINE | DT_LEFT | DT_TOP | DT_CALCRECT); - lpmis->itemHeight = max(ICON_SIZE, max(bmpChecked.bmHeight, rc.bottom)); - lpmis->itemWidth = 2 + bmpChecked.bmWidth + 2 + ICON_SIZE + 4 + rc.right + 2; + lpmis->itemHeight = max(ICON_SIZE, max(bmpChecked.bmHeight, rc.bottom)); + lpmis->itemWidth = 2 + bmpChecked.bmWidth + 2 + ICON_SIZE + 4 + rc.right + 2; - SelectObject(hdc, hFontOld); - DeleteObject(hFont); - ReleaseDC(hwnd, hdc); + SelectObject(hdc, hFontOld); + DeleteObject(hFont); + ReleaseDC(hwnd, hdc); - return TRUE; - } + return TRUE; } return mir_callNextSubclass(hwnd, MenuWndProc, msg, wParam, lParam); } -TCHAR *lstrtrim(TCHAR *str) +TCHAR* lstrtrim(TCHAR *str) { int len = lstrlen(str); int i; - for(i = len - 1; i >= 0 && (str[i] == ' ' || str[i] == '\t'); --i) ; + for (i = len - 1; i >= 0 && (str[i] == ' ' || str[i] == '\t'); --i); if (i < len - 1) { ++i; str[i] = _T('\0'); len = i; } - for(i = 0; i < len && (str[i] == ' ' || str[i] == '\t'); ++i) ; + for (i = 0; i < len && (str[i] == ' ' || str[i] == '\t'); ++i); if (i > 0) memmove(str, &str[i], (len - i + 1) * sizeof(TCHAR)); |