Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class 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);
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   Local Variables:
00289   mode: c++
00290   c-basic-offset: 8
00291   tab-width: 8
00292   c-indent-comments-syntactically-p: t
00293   c-tab-always-indent: t
00294   indent-tabs-mode: t
00295   End:
00296 */
00297 
00298 // vim:shiftwidth=8:autoindent:tabstop=8:noexpandtab:softtabstop=8
00299 

Generated on Mon May 22 12:43:42 2006 for xCHM by  doxygen 1.4.4