00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __CHMFILE_H_
00023 #define __CHMFILE_H_
00024
00025 #include <chm_lib.h>
00026 #include <wx/string.h>
00027 #include <wx/treectrl.h>
00028 #include <wx/listbox.h>
00029 #include <wx/hashmap.h>
00030
00031
00033 WX_DECLARE_STRING_HASH_MAP(wxString, CHMSearchResults);
00034
00035
00037 class CHMFile {
00038 public:
00040 CHMFile();
00041
00047 CHMFile(const wxString& archiveName);
00048
00050 ~CHMFile();
00051
00052
00059 wxString HomePage() const { return _home; }
00060
00068 wxString TopicsFile() const { return _topicsFile; }
00069
00076 wxString ArchiveName() const { return _filename; }
00077
00085 wxString IndexFile() const { return _indexFile; }
00086
00092 wxString Title() const { return _title; }
00093
00099 wxString DefaultFont() const { return _font; }
00100
00107 bool IsOk() const { return _chmFile != NULL; }
00108
00109
00115 bool LoadCHM(const wxString& archiveName);
00116
00118 void CloseCHM();
00119
00129 bool GetTopicsTree(wxTreeCtrl *toBuild);
00130
00131
00142 bool IndexSearch(const wxString& text, bool wholeWords,
00143 bool titlesOnly, CHMSearchResults *results);
00144
00155 bool ResolveObject(const wxString& fileName, chmUnitInfo *ui);
00156
00166 size_t RetrieveObject(chmUnitInfo *ui, unsigned char *buffer,
00167 off_t fileOffset, size_t bufferSize);
00168
00169 private:
00171 bool GetArchiveInfo();
00172
00174 u_int32_t GetLeafNodeOffset(const wxString& text,
00175 u_int32_t initalOffset,
00176 u_int32_t buffSize,
00177 u_int16_t treeDepth,
00178 chmUnitInfo *ui);
00179
00181 bool ProcessWLC(u_int64_t wlc_count, u_int64_t wlc_size,
00182 u_int32_t wlc_offset, unsigned char ds,
00183 unsigned char dr, unsigned char cs,
00184 unsigned char cr, unsigned char ls,
00185 unsigned char lr, chmUnitInfo *uifmain,
00186 chmUnitInfo* uitbl, chmUnitInfo *uistrings,
00187 chmUnitInfo* topics, chmUnitInfo *urlstr,
00188 CHMSearchResults *results);
00189
00190 private:
00191 chmFile* _chmFile;
00192 wxString _filename;
00193 wxString _home;
00194 wxString _topicsFile;
00195 wxString _indexFile;
00196 wxString _title;
00197 wxString _font;
00198
00199 private:
00201 CHMFile(const CHMFile&);
00202
00204 CHMFile& operator=(const CHMFile&);
00205 };
00206
00207
00208 #endif // __CHMFILE_H_