hlpfile.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. struct tagHelpFile;
  23. typedef struct
  24. {
  25. char type[10];
  26. char name[9];
  27. char caption[51];
  28. POINT origin;
  29. SIZE size;
  30. int style;
  31. DWORD win_style;
  32. COLORREF sr_color; /* color for scrollable region */
  33. COLORREF nsr_color; /* color for non scrollable region */
  34. } HLPFILE_WINDOWINFO;
  35. typedef struct tagHlpFileLink
  36. {
  37. enum {hlp_link_link, hlp_link_popup, hlp_link_macro} cookie;
  38. LPCSTR string; /* name of the file to for the link (NULL if same file) */
  39. LONG hash; /* topic index */
  40. unsigned bClrChange : 1; /* true if the link is green & underlined */
  41. unsigned bHotSpot : 1; /* true if the link is an hotspot (actually HLPFILE_HOTSPOTLINK) */
  42. unsigned window; /* window number for displaying the link (-1 is current) */
  43. DWORD cpMin;
  44. DWORD cpMax;
  45. struct tagHlpFileLink* next;
  46. } HLPFILE_LINK;
  47. typedef struct tagHlpFileHotSpotLink
  48. {
  49. HLPFILE_LINK link;
  50. unsigned x;
  51. unsigned y;
  52. unsigned width;
  53. unsigned height;
  54. } HLPFILE_HOTSPOTLINK;
  55. typedef struct tagHlpFileMacro
  56. {
  57. LPCSTR lpszMacro;
  58. struct tagHlpFileMacro* next;
  59. } HLPFILE_MACRO;
  60. typedef struct tagHlpFilePage
  61. {
  62. LPSTR lpszTitle;
  63. HLPFILE_MACRO* first_macro;
  64. HLPFILE_LINK* first_link;
  65. unsigned wNumber;
  66. unsigned offset;
  67. DWORD reference;
  68. struct tagHlpFilePage* next;
  69. struct tagHlpFilePage* prev;
  70. DWORD browse_bwd;
  71. DWORD browse_fwd;
  72. struct tagHlpFileFile* file;
  73. } HLPFILE_PAGE;
  74. typedef struct
  75. {
  76. LONG lMap;
  77. unsigned long offset;
  78. } HLPFILE_MAP;
  79. typedef struct
  80. {
  81. LOGFONTA LogFont;
  82. HFONT hFont;
  83. COLORREF color;
  84. } HLPFILE_FONT;
  85. typedef struct tagHlpFileFile
  86. {
  87. BYTE* file_buffer;
  88. UINT file_buffer_size;
  89. LPSTR lpszPath;
  90. LPSTR lpszTitle;
  91. LPSTR lpszCopyright;
  92. HLPFILE_PAGE* first_page;
  93. HLPFILE_PAGE* last_page;
  94. HLPFILE_MACRO* first_macro;
  95. BYTE* Context;
  96. BYTE* kwbtree;
  97. BYTE* kwdata;
  98. unsigned wMapLen;
  99. HLPFILE_MAP* Map;
  100. unsigned wTOMapLen;
  101. unsigned* TOMap;
  102. unsigned long contents_start;
  103. struct tagHlpFileFile* prev;
  104. struct tagHlpFileFile* next;
  105. unsigned wRefCount;
  106. unsigned short version;
  107. unsigned short flags;
  108. unsigned short charset;
  109. unsigned short tbsize; /* topic block size */
  110. unsigned short dsize; /* decompress size */
  111. BOOL compressed;
  112. BOOL hasPhrases; /* file has |Phrases */
  113. BOOL hasPhrases40; /* file has |PhrIndex/|PhrImage */
  114. UINT num_phrases;
  115. unsigned* phrases_offsets;
  116. char* phrases_buffer;
  117. BYTE** topic_map;
  118. BYTE* topic_end;
  119. UINT topic_maplen;
  120. unsigned numBmps;
  121. HBITMAP* bmps;
  122. unsigned numFonts;
  123. HLPFILE_FONT* fonts;
  124. unsigned numWindows;
  125. HLPFILE_WINDOWINFO* windows;
  126. HICON hIcon;
  127. BOOL has_popup_color;
  128. COLORREF popup_color;
  129. LPSTR help_on_file;
  130. int scale;
  131. int rounderr;
  132. } HLPFILE;
  133. /*
  134. * Compare function type for HLPFILE_BPTreeSearch function.
  135. *
  136. * PARAMS
  137. * p [I] pointer to testing block (key + data)
  138. * key [I] pointer to key value to look for
  139. * leaf [I] whether this function called for index of leaf page
  140. * next [O] pointer to pointer to next block
  141. */
  142. typedef int (*HLPFILE_BPTreeCompare)(void *p, const void *key,
  143. int leaf, void **next);
  144. /*
  145. * Callback function type for HLPFILE_BPTreeEnum function.
  146. *
  147. * PARAMS
  148. * p [I] pointer to data block
  149. * next [O] pointer to pointer to next block
  150. * cookie [IO] cookie data
  151. */
  152. typedef void (*HLPFILE_BPTreeCallback)(void *p, void **next, void *cookie);
  153. HLPFILE* HLPFILE_ReadHlpFile(LPCSTR lpszPath);
  154. HLPFILE_PAGE* HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash, ULONG* relative);
  155. HLPFILE_PAGE* HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap, ULONG* relative);
  156. HLPFILE_PAGE* HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset, ULONG* relative);
  157. LONG HLPFILE_Hash(LPCSTR lpszContext);
  158. void HLPFILE_FreeHlpFile(HLPFILE*);
  159. void HLPFILE_BPTreeEnum(BYTE*, HLPFILE_BPTreeCallback cb, void *cookie);
  160. struct RtfData {
  161. BOOL in_text;
  162. char* data; /* RTF stream start */
  163. char* ptr; /* current position in stream */
  164. unsigned allocated; /* overall allocated size */
  165. unsigned char_pos; /* current char position (in richedit) */
  166. char* where; /* pointer to feed back richedit */
  167. unsigned font_scale; /* how to scale fonts */
  168. HLPFILE_LINK*first_link;
  169. HLPFILE_LINK*current_link;
  170. BOOL force_color;
  171. unsigned relative; /* offset within page to lookup for */
  172. unsigned char_pos_rel; /* char_pos correspondinf to relative */
  173. };
  174. BOOL HLPFILE_BrowsePage(HLPFILE_PAGE*, struct RtfData* rd,
  175. unsigned font_scale, unsigned relative);
  176. #define HLP_DISPLAY30 0x01 /* version 3.0 displayable information */
  177. #define HLP_TOPICHDR 0x02 /* topic header information */
  178. #define HLP_DISPLAY 0x20 /* version 3.1 displayable information */
  179. #define HLP_TABLE 0x23 /* version 3.1 table */