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 <config.h>
00026 #include <chm_lib.h>
00027 #include <wx/filefn.h>
00028 #include <wx/string.h>
00029 #include <wx/hashmap.h>
00030 #include <wx/font.h>
00031 #include <wx/string.h>
00032
00033
00034
00035 class wxTreeCtrl;
00036 class CHMListCtrl;
00037
00038
00040 WX_DECLARE_STRING_HASH_MAP(wxString, CHMSearchResults);
00042 WX_DECLARE_HASH_MAP( int, wxString, wxIntegerHash, wxIntegerEqual, CHMIDMap );
00043
00044
00046 #define MAX_SEARCH_RESULTS 512
00047
00048
00049
00051 class CHMFile {
00052 public:
00054 CHMFile();
00055
00061 CHMFile(const wxString& archiveName);
00062
00064 ~CHMFile();
00065
00066
00073 wxString HomePage() const { return _home; }
00074
00082 wxString TopicsFile() const { return _topicsFile; }
00083
00090 wxString ArchiveName() const { return _filename; }
00091
00099 wxString IndexFile() const { return _indexFile; }
00100
00106 wxString Title() const { return _title; }
00107
00114 bool IsOk() const { return _chmFile != NULL; }
00115
00117 bool HasChanged();
00118
00124 wxFontEncoding DesiredEncoding() const { return _enc; }
00125
00130 wxString DefaultFont() const { return _font; }
00131
00137 bool LoadCHM(const wxString& archiveName);
00138
00140 void CloseCHM();
00141
00151 bool GetTopicsTree(wxTreeCtrl *toBuild);
00152
00162 bool GetIndex(CHMListCtrl* toBuild);
00163
00164
00170 bool LoadContextIDs();
00171
00178 bool IsValidCID( const int contextID );
00179
00186 wxString GetPageByCID( const int contextID );
00187
00192 bool AreContextIDsLoaded() const { return !_cidMap.empty(); }
00193
00204 bool IndexSearch(const wxString& text, bool wholeWords,
00205 bool titlesOnly, CHMSearchResults *results);
00206
00217 bool ResolveObject(const wxString& fileName, chmUnitInfo *ui);
00218
00228 size_t RetrieveObject(chmUnitInfo *ui, unsigned char *buffer,
00229 off_t fileOffset, size_t bufferSize);
00230
00231 private:
00233 wxFontEncoding GetFontEncFromCharSet(int cs);
00234
00236 wxFontEncoding GetFontEncFromLCID(u_int32_t lcid);
00237
00239 bool GetArchiveInfo();
00240
00242 u_int32_t GetLeafNodeOffset(const wxString& text,
00243 u_int32_t initalOffset,
00244 u_int32_t buffSize,
00245 u_int16_t treeDepth,
00246 chmUnitInfo *ui);
00247
00249 bool ProcessWLC(u_int64_t wlc_count, u_int64_t wlc_size,
00250 u_int32_t wlc_offset, unsigned char ds,
00251 unsigned char dr, unsigned char cs,
00252 unsigned char cr, unsigned char ls,
00253 unsigned char lr, chmUnitInfo *uifmain,
00254 chmUnitInfo* uitbl, chmUnitInfo *uistrings,
00255 chmUnitInfo* topics, chmUnitInfo *urlstr,
00256 CHMSearchResults *results);
00257
00259 bool InfoFromWindows();
00260
00262 bool InfoFromSystem();
00263
00264 private:
00265 chmFile* _chmFile;
00266 wxString _filename;
00267 wxString _home;
00268 wxString _topicsFile;
00269 wxString _indexFile;
00270 wxString _title;
00271 wxString _font;
00272 wxFontEncoding _enc;
00273 CHMIDMap _cidMap;
00274
00275 private:
00277 CHMFile(const CHMFile&);
00278
00280 CHMFile& operator=(const CHMFile&);
00281 };
00282
00283
00284 #endif // __CHMFILE_H_
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299