this patch improves a bit link handling in winhelp - better parsing of information in files - allowing links to be macros (and invoking them!) A+
Name: wh_link ChangeLog: improved a bit link handling (a few more link types loaded from file and support for link to a macro License: X11 GenDate: 2002/10/20 09:41:40 UTC ModifiedFiles: programs/winhelp/hlpfile.c programs/winhelp/hlpfile.h programs/winhelp/winhelp.c programs/winhelp/winhelp.h AddedFiles: =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winhelp/hlpfile.c,v retrieving revision 1.10 diff -u -u -r1.10 hlpfile.c --- programs/winhelp/hlpfile.c 19 Oct 2002 00:12:42 -0000 1.10 +++ programs/winhelp/hlpfile.c 19 Oct 2002 07:17:37 -0000 @@ -757,28 +757,31 @@ strcpy(paragraph->u.text.lpszText, text); } - if (attributes.link.lpszPath) + if (attributes.link.lpszString) { /* FIXME: should build a string table for the attributes.link.lpszPath * they are reallocated for each link */ paragraph->link = HeapAlloc(GetProcessHeap(), 0, - sizeof(HLPFILE_LINK) + strlen(attributes.link.lpszPath) + 1); + sizeof(HLPFILE_LINK) + strlen(attributes.link.lpszString) + 1); if (!paragraph->link) return FALSE; - paragraph->link->lpszPath = (char*)paragraph->link + sizeof(HLPFILE_LINK); - strcpy((char*)paragraph->link->lpszPath, attributes.link.lpszPath); - paragraph->link->lHash = attributes.link.lHash; - - paragraph->link->bPopup = attributes.link.bPopup; - WINE_TRACE("Link to %s/%08lx\n", - paragraph->link->lpszPath, paragraph->link->lHash); + paragraph->link->cookie = attributes.link.cookie; + paragraph->link->lpszString = (char*)paragraph->link + sizeof(HLPFILE_LINK); + strcpy((char*)paragraph->link->lpszString, attributes.link.lpszString); + paragraph->link->lHash = attributes.link.lHash; + paragraph->link->bClrChange = attributes.link.bClrChange; + + WINE_TRACE("Link[%d] to %s/%08lx\n", + paragraph->link->cookie, paragraph->link->lpszString, paragraph->link->lHash); } #if 0 memset(&attributes, 0, sizeof(attributes)); #else attributes.hBitmap = 0; - attributes.link.lpszPath = NULL; + attributes.link.lpszString = NULL; + attributes.link.bClrChange = FALSE; + attributes.link.lHash = 0; attributes.wVSpace = 0; attributes.wHSpace = 0; attributes.wIndent = 0; @@ -880,53 +883,67 @@ case 0x8B: case 0x8C: - WINE_FIXME("NIY\n"); + WINE_FIXME("NIY non-break space/hyphen\n"); format += 1; break; #if 0 - case 0xa9: + case 0xA9: format += 2; break; #endif - case 0xc8: - case 0xcc: - WINE_FIXME("macro NIY %s\n", format + 3); - format += GET_USHORT(format, 1) + 3; + case 0xC8: + case 0xCC: + WINE_TRACE("macro => %s\n", format + 3); + attributes.link.bClrChange = !(*format & 4); + attributes.link.cookie = hlp_link_macro; + attributes.link.lpszString = format + 3; + format += 3 + GET_USHORT(format, 1); break; - case 0xe0: - case 0xe1: + case 0xE0: + case 0xE1: WINE_WARN("jump topic 1 => %u\n", GET_UINT(format, 1)); format += 5; break; - case 0xe2: - case 0xe3: - attributes.link.lpszPath = hlpfile->lpszPath; - attributes.link.lHash = GET_UINT(format, 1); - attributes.link.bPopup = !(*format & 1); + case 0xE2: + case 0xE3: + attributes.link.bClrChange = TRUE; + /* fall thru */ + case 0xE6: + case 0xE7: + attributes.link.cookie = (*format & 1) ? hlp_link_link : hlp_link_popup; + attributes.link.lpszString = hlpfile->lpszPath; + attributes.link.lHash = GET_UINT(format, 1); format += 5; break; - case 0xe6: - case 0xe7: - WINE_WARN("jump topic 2 => %u\n", GET_UINT(format, 1)); - format += 5; - break; - - case 0xea: - attributes.link.lpszPath = format + 8; - attributes.link.lHash = GET_UINT(format, 4); - attributes.link.bPopup = !(*format & 1); - format += 3 + GET_USHORT(format, 1); - break; - - case 0xee: - case 0xef: - case 0xeb: - WINE_WARN("jump to external file\n"); + case 0xEA: + case 0xEB: + case 0xEE: + case 0xEF: + { + char* ptr = format + 8; + BYTE type = format[3]; + + attributes.link.cookie = hlp_link_link; + attributes.link.lHash = GET_UINT(format, 4); + attributes.link.bClrChange = !(*format & 1); + + if (type == 1) + {WINE_FIXME("Unsupported wnd number %d for link\n", *ptr); ptr++;} + if (type == 4 || type == 6) + { + attributes.link.lpszString = ptr; + ptr += strlen(ptr) + 1; + } + else + attributes.link.lpszString = hlpfile->lpszPath; + if (type == 6) + WINE_FIXME("Unsupported wnd name '%s' for link\n", ptr); + } format += 3 + GET_USHORT(format, 1); break; Index: programs/winhelp/hlpfile.h =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winhelp/hlpfile.h,v retrieving revision 1.3 diff -u -u -r1.3 hlpfile.h --- programs/winhelp/hlpfile.h 16 Jul 2002 01:46:29 -0000 1.3 +++ programs/winhelp/hlpfile.h 18 Oct 2002 20:53:20 -0000 @@ -23,9 +23,10 @@ typedef struct { - LPCSTR lpszPath; - LONG lHash; - BOOL bPopup; + enum {hlp_link_none, hlp_link_link, hlp_link_popup, hlp_link_macro} cookie; + LPCSTR lpszString; + LONG lHash; + BOOL bClrChange; } HLPFILE_LINK; enum para_type {para_normal_text, para_debug_text, para_image}; Index: programs/winhelp/winhelp.c =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winhelp/winhelp.c,v retrieving revision 1.15 diff -u -u -r1.15 winhelp.c --- programs/winhelp/winhelp.c 19 Oct 2002 00:12:42 -0000 1.15 +++ programs/winhelp/winhelp.c 19 Oct 2002 08:42:03 -0000 @@ -701,8 +696,24 @@ mouse.x = LOWORD(lParam); mouse.y = HIWORD(lParam); - WINHELP_CreateHelpWindowByHash(part->link.lpszPath, part->link.lHash, NULL, - part->link.bPopup, hWnd, &mouse, SW_NORMAL); + switch (part->link.cookie) + { + case hlp_link_none: + break; + case hlp_link_link: + WINHELP_CreateHelpWindowByHash(part->link.lpszString, part->link.lHash, NULL, + FALSE, hWnd, &mouse, SW_NORMAL); + break; + case hlp_link_popup: + WINHELP_CreateHelpWindowByHash(part->link.lpszString, part->link.lHash, NULL, + TRUE, hWnd, &mouse, SW_NORMAL); + break; + case hlp_link_macro: + MACRO_ExecuteMacro(part->link.lpszString); + break; + default: + WINE_FIXME("Unknown link cookie %d\n", part->link.cookie); + } } if (hPopupWnd) @@ -773,7 +784,7 @@ *line_ascent = ascent; line = HeapAlloc(GetProcessHeap(), 0, - sizeof(WINHELP_LINE) + textlen + (link ? lstrlen(link->lpszPath) + 1 : 0)); + sizeof(WINHELP_LINE) + textlen + (link ? lstrlen(link->lpszString) + 1 : 0)); if (!line) return FALSE; line->next = 0; @@ -807,7 +818,7 @@ part = HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE_PART) + textlen + - (link ? lstrlen(link->lpszPath) + 1 : 0)); + (link ? lstrlen(link->lpszString) + 1 : 0)); if (!part) return FALSE; **partp = part; ptr = (char*)part + sizeof(WINHELP_LINE_PART); @@ -836,12 +847,13 @@ part->rect.left, part->rect.top, part->rect.right, part->rect.bottom); if (link) { - strcpy(ptr + textlen, link->lpszPath); - part->link.lpszPath = ptr + textlen; - part->link.lHash = link->lHash; - part->link.bPopup = link->bPopup; + strcpy(ptr + textlen, link->lpszString); + part->link.lpszString = ptr + textlen; + part->link.cookie = link->cookie; + part->link.lHash = link->lHash; + part->link.bClrChange = link->bClrChange; } - else part->link.lpszPath = 0; + else part->link.cookie = hlp_link_none; part->next = 0; *partp = &part->next; @@ -867,7 +879,7 @@ if (!*partp || pos == 1) /* New line */ { line = HeapAlloc(GetProcessHeap(), 0, - sizeof(WINHELP_LINE) + (link ? lstrlen(link->lpszPath) + 1 : 0)); + sizeof(WINHELP_LINE) + (link ? lstrlen(link->lpszString) + 1 : 0)); if (!line) return FALSE; line->next = NULL; @@ -890,7 +902,7 @@ part = HeapAlloc(GetProcessHeap(), 0, sizeof(WINHELP_LINE_PART) + - (link ? lstrlen(link->lpszPath) + 1 : 0)); + (link ? lstrlen(link->lpszString) + 1 : 0)); if (!part) return FALSE; **partp = part; ptr = (char*)part + sizeof(WINHELP_LINE_PART); @@ -912,12 +924,13 @@ if (link) { - strcpy(ptr, link->lpszPath); - part->link.lpszPath = ptr; - part->link.lHash = link->lHash; - part->link.bPopup = link->bPopup; + strcpy(ptr, link->lpszString); + part->link.lpszString = ptr; + part->link.cookie = link->cookie; + part->link.lHash = link->lHash; + part->link.bClrChange = link->bClrChange; } - else part->link.lpszPath = 0; + else part->link.cookie = hlp_link_none; part->next = NULL; *partp = &part->next; @@ -996,7 +1009,7 @@ if (p->link) { - underline = (p->link->bPopup) ? 3 : 1; + underline = (p->link->cookie == hlp_link_popup) ? 3 : 1; color = RGB(0, 0x80, 0); } if (p->cookie == para_debug_text) color = RGB(0xff, 0, 0); @@ -1274,7 +1287,8 @@ { for (part = &line->first_part; part; part = part->next) { - if (part->link.lpszPath && + if (part->link.cookie != hlp_link_none && + part->link.lpszString && part->rect.left <= mouse.x && part->rect.right >= mouse.x && part->rect.top <= mouse.y + scroll_pos && Index: programs/winhelp/winhelp.h =================================================================== RCS file: /home/cvs/cvsroot/wine/wine/programs/winhelp/winhelp.h,v retrieving revision 1.5 diff -u -u -r1.5 winhelp.h --- programs/winhelp/winhelp.h 16 Jul 2002 01:46:29 -0000 1.5 +++ programs/winhelp/winhelp.h 18 Oct 2002 20:32:58 -0000 @@ -56,13 +56,7 @@ HBITMAP hBitmap; } image; } u; - - struct - { - LPCSTR lpszPath; - LONG lHash; - BOOL bPopup; - } link; + HLPFILE_LINK link; struct tagHelpLinePart *next; } WINHELP_LINE_PART;