Commit 7f779920 authored by Dimitrie O. Paun's avatar Dimitrie O. Paun Committed by Alexandre Julliard

Remove the COUNT_OF macro.

Indentation fixes, and minor cleanups to notify_dispinfoT.
parent 6a6310d0
...@@ -297,9 +297,6 @@ static HWND CreateEditLabelT(LISTVIEW_INFO *, LPCWSTR, DWORD, INT, INT, INT, INT ...@@ -297,9 +297,6 @@ static HWND CreateEditLabelT(LISTVIEW_INFO *, LPCWSTR, DWORD, INT, INT, INT, INT
/******** Defines that LISTVIEW_ProcessLetterKeys uses ****************/ /******** Defines that LISTVIEW_ProcessLetterKeys uses ****************/
#define KEY_DELAY 450 #define KEY_DELAY 450
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
/******** Text handling functions *************************************/ /******** Text handling functions *************************************/
/* A text pointer is either NULL, LPSTR_TEXTCALLBACK, or points to a /* A text pointer is either NULL, LPSTR_TEXTCALLBACK, or points to a
...@@ -570,34 +567,25 @@ static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNML ...@@ -570,34 +567,25 @@ static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNML
INT cchTempBufMax = 0, savCchTextMax = 0; INT cchTempBufMax = 0, savCchTextMax = 0;
LPWSTR pszTempBuf = NULL, savPszText = NULL; LPWSTR pszTempBuf = NULL, savPszText = NULL;
TRACE("(code=%x, pdi=%p, isW=%d)\n", notificationCode, pdi, isW);
TRACE(" notifyFormat=%s\n",
infoPtr->notifyFormat == NFR_UNICODE ? "NFR_UNICODE" :
infoPtr->notifyFormat == NFR_ANSI ? "NFR_ANSI" : "(not set)");
if (infoPtr->notifyFormat == NFR_ANSI)
realNotifCode = get_ansi_notification(notificationCode);
else
realNotifCode = notificationCode;
if ((pdi->item.mask & LVIF_TEXT) && is_textT(pdi->item.pszText, isW)) if ((pdi->item.mask & LVIF_TEXT) && is_textT(pdi->item.pszText, isW))
{ {
if (isW && infoPtr->notifyFormat == NFR_ANSI) convertToAnsi = (isW && infoPtr->notifyFormat == NFR_ANSI);
convertToAnsi = TRUE; convertToUnicode = (!isW && infoPtr->notifyFormat == NFR_UNICODE);
if (!isW && infoPtr->notifyFormat == NFR_UNICODE)
convertToUnicode = TRUE;
} }
if (convertToAnsi || convertToUnicode) if (convertToAnsi || convertToUnicode)
{ {
TRACE(" we have to convert the text to the correct format\n");
if (notificationCode != LVN_GETDISPINFOW) if (notificationCode != LVN_GETDISPINFOW)
{ /* length of existing text */ {
cchTempBufMax = convertToUnicode ? cchTempBufMax = convertToUnicode ?
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, NULL, 0): MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, NULL, 0):
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, NULL, 0, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, NULL, 0, NULL, NULL);
} }
else else
{
cchTempBufMax = pdi->item.cchTextMax; cchTempBufMax = pdi->item.cchTextMax;
pdi->item.pszText = 0; /* make sure we don't process garbage */
}
pszTempBuf = HeapAlloc(GetProcessHeap(), 0, pszTempBuf = HeapAlloc(GetProcessHeap(), 0,
(convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax); (convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax);
...@@ -608,18 +596,20 @@ static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNML ...@@ -608,18 +596,20 @@ static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNML
else else
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) pszTempBuf, WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) pszTempBuf,
cchTempBufMax, NULL, NULL); cchTempBufMax, NULL, NULL);
TRACE(" text=%s\n", debugtext_t(pszTempBuf, convertToUnicode));
savCchTextMax = pdi->item.cchTextMax; savCchTextMax = pdi->item.cchTextMax;
savPszText = pdi->item.pszText; savPszText = pdi->item.pszText;
pdi->item.pszText = pszTempBuf; pdi->item.pszText = pszTempBuf;
pdi->item.cchTextMax = cchTempBufMax; pdi->item.cchTextMax = cchTempBufMax;
} }
if (infoPtr->notifyFormat == NFR_ANSI)
realNotifCode = get_ansi_notification(notificationCode);
else
realNotifCode = notificationCode;
bResult = notify(infoPtr, realNotifCode, (LPNMHDR)pdi); bResult = notify(infoPtr, realNotifCode, (LPNMHDR)pdi);
if (convertToUnicode || convertToAnsi) if (convertToUnicode || convertToAnsi)
{ /* convert back result */ {
TRACE(" returned text=%s\n", debugtext_t(pdi->item.pszText, convertToUnicode));
if (convertToUnicode) /* note : pointer can be changed by app ! */ if (convertToUnicode) /* note : pointer can be changed by app ! */
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) savPszText, WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) savPszText,
savCchTextMax, NULL, NULL); savCchTextMax, NULL, NULL);
...@@ -904,7 +894,7 @@ static INT LISTVIEW_ProcessLetterKeys(LISTVIEW_INFO *infoPtr, WPARAM charCode, L ...@@ -904,7 +894,7 @@ static INT LISTVIEW_ProcessLetterKeys(LISTVIEW_INFO *infoPtr, WPARAM charCode, L
/* update the search parameters */ /* update the search parameters */
infoPtr->lastKeyPressTimestamp=timestamp; infoPtr->lastKeyPressTimestamp=timestamp;
if (elapsed < KEY_DELAY) { if (elapsed < KEY_DELAY) {
if (infoPtr->nSearchParamLength < COUNTOF(infoPtr->szSearchParam)) { if (infoPtr->nSearchParamLength < MAX_PATH) {
infoPtr->szSearchParam[infoPtr->nSearchParamLength++]=charCode; infoPtr->szSearchParam[infoPtr->nSearchParamLength++]=charCode;
} }
if (infoPtr->charCode != charCode) { if (infoPtr->charCode != charCode) {
...@@ -944,7 +934,7 @@ static INT LISTVIEW_ProcessLetterKeys(LISTVIEW_INFO *infoPtr, WPARAM charCode, L ...@@ -944,7 +934,7 @@ static INT LISTVIEW_ProcessLetterKeys(LISTVIEW_INFO *infoPtr, WPARAM charCode, L
item.iItem = idx; item.iItem = idx;
item.iSubItem = 0; item.iSubItem = 0;
item.pszText = buffer; item.pszText = buffer;
item.cchTextMax = COUNTOF(buffer); item.cchTextMax = MAX_PATH;
if (!LISTVIEW_GetItemW(infoPtr, &item)) return 0; if (!LISTVIEW_GetItemW(infoPtr, &item)) return 0;
/* check for a match */ /* check for a match */
...@@ -3002,7 +2992,7 @@ static BOOL LISTVIEW_DrawSubItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, ...@@ -3002,7 +2992,7 @@ static BOOL LISTVIEW_DrawSubItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem,
lvItem.mask = LVIF_TEXT | LVIF_IMAGE; lvItem.mask = LVIF_TEXT | LVIF_IMAGE;
lvItem.iItem = nItem; lvItem.iItem = nItem;
lvItem.iSubItem = nSubItem; lvItem.iSubItem = nSubItem;
lvItem.cchTextMax = COUNTOF(szDispText); lvItem.cchTextMax = DISP_TEXT_SIZE;
lvItem.pszText = szDispText; lvItem.pszText = szDispText;
*lvItem.pszText = '\0'; *lvItem.pszText = '\0';
if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return FALSE; if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment