hlpfile.h 6.58 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1 2 3
/*
 * Help Viewer
 *
4
 * Copyright    1996 Ulrich Schmid
5
 *              2002, 2008 Eric Pouech
6
 *              2007 Kirill K. Smirnov
7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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
Alexandre Julliard's avatar
Alexandre Julliard committed
21 22 23 24
 */

struct tagHelpFile;

25 26 27 28 29 30 31 32 33
typedef struct 
{
    char        type[10];
    char        name[9];
    char        caption[51];
    POINT       origin;
    SIZE        size;
    int         style;
    DWORD       win_style;
34
    COLORREF    sr_color;       /* color for scrollable region */
35 36 37
    COLORREF    nsr_color;      /* color for non scrollable region */
} HLPFILE_WINDOWINFO;

38
typedef struct tagHlpFileLink
Alexandre Julliard's avatar
Alexandre Julliard committed
39
{
40
    enum {hlp_link_link, hlp_link_popup, hlp_link_macro} cookie;
41 42
    LPCSTR      string;         /* name of the file to for the link (NULL if same file) */
    LONG        hash;           /* topic index */
43
    unsigned    bClrChange : 1; /* true if the link is green & underlined */
44
    unsigned    window;         /* window number for displaying the link (-1 is current) */
45 46 47
    DWORD       cpMin;
    DWORD       cpMax;
    struct tagHlpFileLink* next;
Alexandre Julliard's avatar
Alexandre Julliard committed
48 49
} HLPFILE_LINK;

50 51 52 53 54 55
typedef struct tagHlpFileMacro
{
    LPCSTR                      lpszMacro;
    struct tagHlpFileMacro*     next;
} HLPFILE_MACRO;

Alexandre Julliard's avatar
Alexandre Julliard committed
56 57
typedef struct tagHlpFilePage
{
58
    LPSTR                       lpszTitle;
59
    HLPFILE_MACRO*              first_macro;
60

61 62
    HLPFILE_LINK*               first_link;

63 64
    unsigned                    wNumber;
    unsigned                    offset;
65
    DWORD                       reference;
66 67
    struct tagHlpFilePage*      next;
    struct tagHlpFilePage*      prev;
68 69 70 71

    DWORD                       browse_bwd;
    DWORD                       browse_fwd;

72
    struct tagHlpFileFile*      file;
Alexandre Julliard's avatar
Alexandre Julliard committed
73 74
} HLPFILE_PAGE;

75 76 77 78 79 80
typedef struct
{
    LONG                        lMap;
    unsigned long               offset;
} HLPFILE_MAP;

81
typedef struct
Alexandre Julliard's avatar
Alexandre Julliard committed
82
{
83 84 85 86
    LOGFONT                     LogFont;
    HFONT                       hFont;
    COLORREF                    color;
} HLPFILE_FONT;
Alexandre Julliard's avatar
Alexandre Julliard committed
87

88 89
typedef struct tagHlpFileFile
{
90 91
    BYTE*                       file_buffer;
    UINT                        file_buffer_size;
92 93
    LPSTR                       lpszPath;
    LPSTR                       lpszTitle;
Eric Pouech's avatar
Eric Pouech committed
94
    LPSTR                       lpszCopyright;
95
    HLPFILE_PAGE*               first_page;
96
    HLPFILE_PAGE*               last_page;
97
    HLPFILE_MACRO*              first_macro;
98
    BYTE*                       Context;
99 100
    BYTE*                       kwbtree;
    BYTE*                       kwdata;
101 102
    unsigned                    wMapLen;
    HLPFILE_MAP*                Map;
Eric Pouech's avatar
Eric Pouech committed
103 104
    unsigned long               contents_start;

105 106 107 108 109 110 111
    struct tagHlpFileFile*      prev;
    struct tagHlpFileFile*      next;

    unsigned                    wRefCount;

    unsigned short              version;
    unsigned short              flags;
112
    unsigned short              charset;
113 114 115
    unsigned short              tbsize;     /* topic block size */
    unsigned short              dsize;      /* decompress size */
    unsigned short              compressed;
116 117
    unsigned                    hasPhrases;   /* file has |Phrases */
    unsigned                    hasPhrases40; /* file has |PhrIndex/|PhrImage */
118 119 120 121 122 123 124
    UINT                        num_phrases;
    unsigned*                   phrases_offsets;
    char*                       phrases_buffer;

    BYTE**                      topic_map;
    BYTE*                       topic_end;
    UINT                        topic_maplen;
125

Eric Pouech's avatar
Eric Pouech committed
126 127 128
    unsigned                    numBmps;
    HBITMAP*                    bmps;

129 130
    unsigned                    numFonts;
    HLPFILE_FONT*               fonts;
131 132 133

    unsigned                    numWindows;
    HLPFILE_WINDOWINFO*         windows;
134
    HICON                       hIcon;
Alexandre Julliard's avatar
Alexandre Julliard committed
135 136
} HLPFILE;

137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
/*
 * Compare function type for HLPFILE_BPTreeSearch function.
 *
 * PARAMS
 *     p       [I] pointer to testing block (key + data)
 *     key     [I] pointer to key value to look for
 *     leaf    [I] whether this function called for index of leaf page
 *     next    [O] pointer to pointer to next block
 */
typedef int (*HLPFILE_BPTreeCompare)(void *p, const void *key,
                                     int leaf, void **next);

/*
 * Callback function type for HLPFILE_BPTreeEnum function.
 *
 * PARAMS
 *     p       [I]  pointer to data block
 *     next    [O]  pointer to pointer to next block
 *     cookie  [IO] cookie data
 */
typedef void (*HLPFILE_BPTreeCallback)(void *p, void **next, void *cookie);

159
HLPFILE*      HLPFILE_ReadHlpFile(LPCSTR lpszPath);
160 161 162 163
HLPFILE_PAGE* HLPFILE_Contents(HLPFILE* hlpfile, ULONG* relative);
HLPFILE_PAGE* HLPFILE_PageByHash(HLPFILE* hlpfile, LONG lHash, ULONG* relative);
HLPFILE_PAGE* HLPFILE_PageByMap(HLPFILE* hlpfile, LONG lMap, ULONG* relative);
HLPFILE_PAGE* HLPFILE_PageByOffset(HLPFILE* hlpfile, LONG offset, ULONG* relative);
Alexandre Julliard's avatar
Alexandre Julliard committed
164
LONG          HLPFILE_Hash(LPCSTR lpszContext);
165
void          HLPFILE_FreeHlpFile(HLPFILE*);
166 167 168 169 170 171
unsigned      HLPFILE_HalfPointsToTwips(unsigned pts);

static inline unsigned HLPFILE_PointsToTwips(unsigned pts)
{
    return HLPFILE_HalfPointsToTwips(2 * pts);
}
172 173 174

void* HLPFILE_BPTreeSearch(BYTE*, const void*, HLPFILE_BPTreeCompare);
void  HLPFILE_BPTreeEnum(BYTE*, HLPFILE_BPTreeCallback cb, void *cookie);
175

176 177 178 179 180 181 182
struct RtfData {
    BOOL        in_text;
    char*       data;           /* RTF stream start */
    char*       ptr;            /* current position in stream */
    unsigned    allocated;      /* overall allocated size */
    unsigned    char_pos;       /* current char position (in richedit) */
    char*       where;          /* pointer to feed back richedit */
183
    unsigned    font_scale;     /* how to scale fonts */
184 185
    HLPFILE_LINK*first_link;
    HLPFILE_LINK*current_link;
186
    BOOL        force_color;
187 188
    unsigned    relative;       /* offset within page to lookup for */
    unsigned    char_pos_rel;   /* char_pos correspondinf to relative */
189 190
};

191 192
BOOL          HLPFILE_BrowsePage(HLPFILE_PAGE*, struct RtfData* rd,
                                 unsigned font_scale, unsigned relative);