1 /* 2 * Help Viewer 3 * 4 * Copyright 1996 Ulrich Schmid 5 * 2002, 2008 Eric Pouech 6 * 2007 Kirill K. Smirnov 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 21 */ 22 23 #pragma once 24 25 struct tagHelpFile; 26 27 typedef struct 28 { 29 char type[10]; 30 char name[9]; 31 char caption[51]; 32 POINT origin; 33 SIZE size; 34 int style; 35 DWORD win_style; 36 COLORREF sr_color; /* color for scrollable region */ 37 COLORREF nsr_color; /* color for non scrollable region */ 38 } HLPFILE_WINDOWINFO; 39 40 typedef struct tagHlpFileLink 41 { 42 enum {hlp_link_link, hlp_link_popup, hlp_link_macro} cookie; 43 LPCSTR string; /* name of the file to for the link (NULL if same file) */ 44 LONG hash; /* topic index */ 45 unsigned bClrChange : 1; /* true if the link is green & underlined */ 46 unsigned bHotSpot : 1; /* true if the link is an hotspot (actually HLPFILE_HOTSPOTLINK) */ 47 unsigned window; /* window number for displaying the link (-1 is current) */ 48 DWORD cpMin; 49 DWORD cpMax; 50 struct tagHlpFileLink* next; 51 } HLPFILE_LINK; 52 53 typedef struct tagHlpFileHotSpotLink 54 { 55 HLPFILE_LINK link; 56 unsigned x; 57 unsigned y; 58 unsigned width; 59 unsigned height; 60 } HLPFILE_HOTSPOTLINK; 61 62 typedef struct tagHlpFileMacro 63 { 64 LPCSTR lpszMacro; 65 struct tagHlpFileMacro* next; 66 } HLPFILE_MACRO; 67 68 typedef struct tagHlpFilePage 69 { 70 LPSTR lpszTitle; 71 HLPFILE_MACRO* first_macro; 72 73 HLPFILE_LINK* first_link; 74 75 unsigned wNumber; 76 unsigned offset; 77 DWORD reference; 78 struct tagHlpFilePage* next; 79 struct tagHlpFilePage* prev; 80 81 DWORD browse_bwd; 82 DWORD browse_fwd; 83 84 struct tagHlpFileFile* file; 85 } HLPFILE_PAGE; 86 87 typedef struct 88 { 89 LONG lMap; 90 unsigned long offset; 91 } HLPFILE_MAP; 92 93 typedef struct 94 { 95 LOGFONTA LogFont; 96 HFONT hFont; 97 COLORREF color; 98 } HLPFILE_FONT; 99 100 typedef struct tagHlpFileFile 101 { 102 BYTE* file_buffer; 103 UINT file_buffer_size; 104 LPSTR lpszPath; 105 LPSTR lpszTitle; 106 LPSTR lpszCopyright; 107 HLPFILE_PAGE* first_page; 108 HLPFILE_PAGE* last_page; 109 HLPFILE_MACRO* first_macro; 110 BYTE* Context; 111 BYTE* kwbtree; 112 BYTE* kwdata; 113 unsigned wMapLen; 114 HLPFILE_MAP* Map; 115 unsigned wTOMapLen; 116 unsigned* TOMap; 117 unsigned long contents_start; 118 119 struct tagHlpFileFile* prev; 120 struct tagHlpFileFile* next; 121 122 unsigned wRefCount; 123 124 unsigned short version; 125 unsigned short flags; 126 unsigned short charset; 127 unsigned short tbsize; /* topic block size */ 128 unsigned short dsize; /* decompress size */ 129 BOOL compressed; 130 BOOL hasPhrases; /* file has |Phrases */ 131 BOOL hasPhrases40; /* file has |PhrIndex/|PhrImage */ 132 UINT num_phrases; 133 unsigned* phrases_offsets; 134 char* phrases_buffer; 135 136 BYTE** topic_map; 137 BYTE* topic_end; 138 UINT topic_maplen; 139 140 unsigned numBmps; 141 HBITMAP* bmps; 142 143 unsigned numFonts; 144 HLPFILE_FONT* fonts; 145 146 unsigned numWindows; 147 HLPFILE_WINDOWINFO* windows; 148 HICON hIcon; 149 150 BOOL has_popup_color; 151 COLORREF popup_color; 152 153 LPSTR help_on_file; 154 155 int scale; 156 int rounderr; 157 } HLPFILE; 158 159 /* 160 * Compare function type for HLPFILE_BPTreeSearch function. 161 * 162 * PARAMS 163 * p [I] pointer to testing block (key + data) 164 * key [I] pointer to key value to look for 165 * leaf [I] whether this function called for index of leaf page 166 * next [O] pointer to pointer to next block 167 */ 168 typedef int (*HLPFILE_BPTreeCompare)(void *p, const void *key, 169 int leaf, void **next); 170 171 /* 172 * Callback function type for HLPFILE_BPTreeEnum function. 173 * 174 * PARAMS 175 * p [I] pointer to data block 176 * next [O] pointer to pointer to next block 177 * cookie [IO] cookie data 178 */ 179 typedef void (*HLPFILE_BPTreeCallback)(void *p, void **next, void *cookie); 180 181 HLPFILE* HLPFILE_ReadHlpFile(LPCSTR lpszPath); 182 HLPFILE_PAGE* HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash, ULONG* relative); 183 HLPFILE_PAGE* HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap, ULONG* relative); 184 HLPFILE_PAGE* HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset, ULONG* relative); 185 LONG HLPFILE_Hash(LPCSTR lpszContext); 186 void HLPFILE_FreeHlpFile(HLPFILE*); 187 188 void HLPFILE_BPTreeEnum(BYTE*, HLPFILE_BPTreeCallback cb, void *cookie); 189 190 struct RtfData { 191 BOOL in_text; 192 char* data; /* RTF stream start */ 193 char* ptr; /* current position in stream */ 194 unsigned allocated; /* overall allocated size */ 195 unsigned char_pos; /* current char position (in richedit) */ 196 char* where; /* pointer to feed back richedit */ 197 unsigned font_scale; /* how to scale fonts */ 198 HLPFILE_LINK*first_link; 199 HLPFILE_LINK*current_link; 200 BOOL force_color; 201 unsigned relative; /* offset within page to lookup for */ 202 unsigned char_pos_rel; /* char_pos correspondinf to relative */ 203 }; 204 205 BOOL HLPFILE_BrowsePage(HLPFILE_PAGE*, struct RtfData* rd, 206 unsigned font_scale, unsigned relative); 207 208 #define HLP_DISPLAY30 0x01 /* version 3.0 displayable information */ 209 #define HLP_TOPICHDR 0x02 /* topic header information */ 210 #define HLP_DISPLAY 0x20 /* version 3.1 displayable information */ 211 #define HLP_TABLE 0x23 /* version 3.1 table */ 212