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
...@@ -564,73 +561,66 @@ static int get_ansi_notification(INT unicodeNotificationCode) ...@@ -564,73 +561,66 @@ static int get_ansi_notification(INT unicodeNotificationCode)
*/ */
static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNMLVDISPINFOW pdi, BOOL isW) static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNMLVDISPINFOW pdi, BOOL isW)
{ {
BOOL bResult = FALSE; BOOL bResult = FALSE;
BOOL convertToAnsi = FALSE, convertToUnicode = FALSE; BOOL convertToAnsi = FALSE, convertToUnicode = FALSE;
INT realNotifCode; INT realNotifCode;
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)
{
TRACE(" we have to convert the text to the correct format\n");
if (notificationCode != LVN_GETDISPINFOW)
{ /* length of existing text */
cchTempBufMax = convertToUnicode ?
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, NULL, 0):
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, NULL, 0, NULL, NULL);
} }
else
cchTempBufMax = pdi->item.cchTextMax;
pszTempBuf = HeapAlloc(GetProcessHeap(), 0,
(convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax);
if (!pszTempBuf) return FALSE;
if (convertToUnicode)
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1,
pszTempBuf, cchTempBufMax);
else
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) pszTempBuf,
cchTempBufMax, NULL, NULL);
TRACE(" text=%s\n", debugtext_t(pszTempBuf, convertToUnicode));
savCchTextMax = pdi->item.cchTextMax;
savPszText = pdi->item.pszText;
pdi->item.pszText = pszTempBuf;
pdi->item.cchTextMax = cchTempBufMax;
}
bResult = notify(infoPtr, realNotifCode, (LPNMHDR)pdi); if (convertToAnsi || convertToUnicode)
{
if (notificationCode != LVN_GETDISPINFOW)
{
cchTempBufMax = convertToUnicode ?
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, NULL, 0):
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, NULL, 0, NULL, NULL);
}
else
{
cchTempBufMax = pdi->item.cchTextMax;
pdi->item.pszText = 0; /* make sure we don't process garbage */
}
if (convertToUnicode || convertToAnsi) pszTempBuf = HeapAlloc(GetProcessHeap(), 0,
{ /* convert back result */ (convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax);
TRACE(" returned text=%s\n", debugtext_t(pdi->item.pszText, convertToUnicode)); if (!pszTempBuf) return FALSE;
if (convertToUnicode) /* note : pointer can be changed by app ! */ if (convertToUnicode)
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) savPszText, MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1,
savCchTextMax, NULL, NULL); pszTempBuf, cchTempBufMax);
else
WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) pszTempBuf,
cchTempBufMax, NULL, NULL);
savCchTextMax = pdi->item.cchTextMax;
savPszText = pdi->item.pszText;
pdi->item.pszText = pszTempBuf;
pdi->item.cchTextMax = cchTempBufMax;
}
if (infoPtr->notifyFormat == NFR_ANSI)
realNotifCode = get_ansi_notification(notificationCode);
else else
MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1, realNotifCode = notificationCode;
savPszText, savCchTextMax); bResult = notify(infoPtr, realNotifCode, (LPNMHDR)pdi);
pdi->item.pszText = savPszText; /* restores our buffer */
pdi->item.cchTextMax = savCchTextMax; if (convertToUnicode || convertToAnsi)
HeapFree(GetProcessHeap(), 0, pszTempBuf); {
} if (convertToUnicode) /* note : pointer can be changed by app ! */
return bResult; WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) savPszText,
savCchTextMax, NULL, NULL);
else
MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1,
savPszText, savCchTextMax);
pdi->item.pszText = savPszText; /* restores our buffer */
pdi->item.cchTextMax = savCchTextMax;
HeapFree(GetProcessHeap(), 0, pszTempBuf);
}
return bResult;
} }
static inline void notify_odcachehint(LISTVIEW_INFO *infoPtr, INT iFrom, INT iTo) static inline void notify_odcachehint(LISTVIEW_INFO *infoPtr, INT iFrom, INT iTo)
...@@ -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