Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members

chmfile.h

00001 /*
00002 
00003   Copyright (C) 2003  Razvan Cojocaru <razvanco@gmx.net>
00004  
00005   This program is free software; you can redistribute it and/or modify
00006   it under the terms of the GNU General Public License as published by
00007   the Free Software Foundation; either version 2 of the License, or
00008   (at your option) any later version.
00009   
00010   This program is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013   GNU General Public License for more details.
00014   
00015   You should have received a copy of the GNU General Public License
00016   along with this program; if not, write to the Free Software
00017   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 // Forward declarations.
00035 class wxTreeCtrl;
00036 class CHMListCtrl;
00037 
00038 
00040 WX_DECLARE_STRING_HASH_MAP(wxString, CHMSearchResults);
00041 
00042 
00044 class CHMFile {
00045 public:
00047         CHMFile();
00048         
00054         CHMFile(const wxString& archiveName);
00055 
00057         ~CHMFile();
00058 
00059         
00066         wxString HomePage() const { return _home; }
00067 
00075         wxString TopicsFile() const { return _topicsFile; }
00076 
00083         wxString ArchiveName() const { return _filename; }
00084 
00092         wxString IndexFile() const { return _indexFile; }
00093 
00099         wxString Title() const { return _title; }
00100 
00106         wxString DefaultFont() const { return _font; }
00107 
00114         bool IsOk() const { return _chmFile != NULL; }
00115 
00116 
00122         wxFontEncoding DesiredEncoding() const { return _enc; }
00123 
00129         bool LoadCHM(const wxString& archiveName);
00130 
00132         void CloseCHM();
00133 
00143         bool GetTopicsTree(wxTreeCtrl *toBuild);
00144 
00154         bool GetIndex(CHMListCtrl* toBuild);
00155 
00156 
00167         bool IndexSearch(const wxString& text, bool wholeWords, 
00168                          bool titlesOnly, CHMSearchResults *results);
00169 
00180         bool ResolveObject(const wxString& fileName, chmUnitInfo *ui);
00181 
00191         size_t RetrieveObject(chmUnitInfo *ui, unsigned char *buffer,
00192                               off_t fileOffset, size_t bufferSize);
00193 
00194 private:
00196         wxFontEncoding GetFontEncFromCharSet(int cs);
00197 
00199         bool GetArchiveInfo();
00200 
00202         u_int32_t GetLeafNodeOffset(const wxString& text,
00203                                     u_int32_t initalOffset,
00204                                     u_int32_t buffSize,
00205                                     u_int16_t treeDepth,
00206                                     chmUnitInfo *ui);
00207 
00209         bool ProcessWLC(u_int64_t wlc_count, u_int64_t wlc_size,
00210                         u_int32_t wlc_offset, unsigned char ds,
00211                         unsigned char dr, unsigned char cs,
00212                         unsigned char cr, unsigned char ls,
00213                         unsigned char lr, chmUnitInfo *uifmain,
00214                         chmUnitInfo* uitbl, chmUnitInfo *uistrings,
00215                         chmUnitInfo* topics, chmUnitInfo *urlstr,
00216                         CHMSearchResults *results);
00217 
00219         void GetFileAsString(wxString& str, chmUnitInfo *ui);
00220 
00222         bool InfoFromWindows();
00223 
00225         bool InfoFromSystem();
00226 
00227 private:
00228         chmFile* _chmFile;
00229         wxString _filename;
00230         wxString _home;
00231         wxString _topicsFile;
00232         wxString _indexFile;
00233         wxString _title;
00234         wxString _font;
00235         wxFontEncoding _enc;
00236 
00237 private:
00239         CHMFile(const CHMFile&);
00240 
00242         CHMFile& operator=(const CHMFile&);
00243 };
00244 
00245 
00246 #endif // __CHMFILE_H_

Generated on Fri Jan 23 11:06:47 2004 for xCHM by doxygen 1.3.3