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

CHMFile Class Reference

Mostly a C++ wrapper around the CHMLIB facilities. Concrete class. More...

#include <chmfile.h>

List of all members.

Public Member Functions

 CHMFile ()
 Default constructor.
 CHMFile (const wxString &archiveName)
 This constructor attempts to open the .chm file passed as it's argument. If it fails, IsOk() will return false.
 ~CHMFile ()
 Destructor. If a file has been succesfully opened, it closes it.
wxString HomePage () const
 Gets the name of the default page in the archive.
wxString TopicsFile () const
 Gets name of the .hhc file in the archive that could potentially be used to generate content information from.
wxString ArchiveName () const
 Gets the filename of the currently opened .chm file.
wxString IndexFile () const
 Gets name of the .hhk file in the archive that could potentially be used to generate content information from.
wxString Title () const
 Gets the name of the opened .chm.
bool IsOk () const
 Checks if the last attempt to load a .chm file was succesful.
bool HasChanged ()
 Checks if a 'ms-its' link has been clicked and the chm changed.
wxFontEncoding DesiredEncoding () const
 Determines the encoding that the CHM creator would like me to use. To be used in combination with DefaultFont().
wxString DefaultFont () const
 Determines the font to use for special charsets.
bool LoadCHM (const wxString &archiveName)
 Attempts to load a .chm file from disk.
void CloseCHM ()
 Closes the currently opened .chm, or does nothing if none opened.
bool GetTopicsTree (wxTreeCtrl *toBuild)
 Attempts to fill a wxTreeCtrl by parsing the topics file.
bool GetIndex (CHMListCtrl *toBuild)
 Attempts to fill a CHMListCtrl by parsing the index file.
bool LoadContextIDs ()
 Attempts to build an index of context-ID/page pairs from the file.
bool IsValidCID (const int contextID)
 Checks whether or not the context ID is valid for the loaded file.
wxString GetPageByCID (const int contextID)
 Looks up the page referred to by the context-ID.
bool AreContextIDsLoaded () const
 Have the context-IDs been loaded into memory or not.
bool IndexSearch (const wxString &text, bool wholeWords, bool titlesOnly, CHMSearchResults *results)
 Fast search using the $FIftiMain file in the .chm.
bool ResolveObject (const wxString &fileName, chmUnitInfo *ui)
 Looks up fileName in the archive.
size_t RetrieveObject (chmUnitInfo *ui, unsigned char *buffer, off_t fileOffset, size_t bufferSize)
 Retrieves an uncompressed chunk of a file in the .chm.

Private Member Functions

wxFontEncoding GetFontEncFromCharSet (int cs)
 Helper. Translates from Win32 encodings to generic wxWidgets ones.
wxFontEncoding GetFontEncFromLCID (u_int32_t lcid)
 Helper. Translates from MS-specific LCID.
bool GetArchiveInfo ()
 Helper. Initializes most of the private data members.
u_int32_t GetLeafNodeOffset (const wxString &text, u_int32_t initalOffset, u_int32_t buffSize, u_int16_t treeDepth, chmUnitInfo *ui)
 Helper. Returns the $FIftiMain offset of leaf node or 0.
bool ProcessWLC (u_int64_t wlc_count, u_int64_t wlc_size, u_int32_t wlc_offset, unsigned char ds, unsigned char dr, unsigned char cs, unsigned char cr, unsigned char ls, unsigned char lr, chmUnitInfo *uifmain, chmUnitInfo *uitbl, chmUnitInfo *uistrings, chmUnitInfo *topics, chmUnitInfo *urlstr, CHMSearchResults *results)
 Helper. Processes the word location code entries while searching.
bool InfoFromWindows ()
 Looks up as much information as possible from WINDOWS/STRINGS.
bool InfoFromSystem ()
 Looks up as much information as possible from SYSTEM.
 CHMFile (const CHMFile &)
 No copy construction allowed.
CHMFileoperator= (const CHMFile &)
 No assignments.

Private Attributes

chmFile * _chmFile
wxString _filename
wxString _home
wxString _topicsFile
wxString _indexFile
wxString _title
wxString _font
wxFontEncoding _enc
CHMIDMap _cidMap


Detailed Description

Mostly a C++ wrapper around the CHMLIB facilities. Concrete class.


Constructor & Destructor Documentation

CHMFile::CHMFile const wxString &  archiveName  ) 
 

This constructor attempts to open the .chm file passed as it's argument. If it fails, IsOk() will return false.

Parameters:
archiveName The .chm filename on disk.


Member Function Documentation

wxString CHMFile::ArchiveName  )  const [inline]
 

Gets the filename of the currently opened .chm file.

Returns:
The filename of the currently opened archive, relative to the root of the filesystem, or the empty string if no archive has been opened.

bool CHMFile::AreContextIDsLoaded  )  const [inline]
 

Have the context-IDs been loaded into memory or not.

Returns:
true if they have, false if not.

wxString CHMFile::DefaultFont  )  const [inline]
 

Determines the font to use for special charsets.

Returns:
Detected font recommendation.

wxFontEncoding CHMFile::DesiredEncoding  )  const [inline]
 

Determines the encoding that the CHM creator would like me to use. To be used in combination with DefaultFont().

Returns:
Desired encoding.

bool CHMFile::GetIndex CHMListCtrl toBuild  ) 
 

Attempts to fill a CHMListCtrl by parsing the index file.

Parameters:
toBuild Pointer to the list control to be filled. If the index file is not available, the list control is unmodified. The lost must be empty before passing it to this function.
Returns:
true if it's possible to build the tree, false otherwise.

wxString CHMFile::GetPageByCID const int  contextID  ) 
 

Looks up the page referred to by the context-ID.

Parameters:
contextID The context-ID to look up
Returns:
the page referred to by the context-ID, or file root"/" if ID is invalid.

bool CHMFile::GetTopicsTree wxTreeCtrl *  toBuild  ) 
 

Attempts to fill a wxTreeCtrl by parsing the topics file.

Parameters:
toBuild Pointer to the tree to be filled. If the topics file is not available, the tree is unmodified. The tree must be empty before passing it to this function.
Returns:
true if it's possible to build the tree, false otherwise.

wxString CHMFile::HomePage  )  const [inline]
 

Gets the name of the default page in the archive.

Returns:
The home page name, with a '/' added in front and relative to the root of the archive filesystem. If no .chm has been opened, the returned value is "/".

wxString CHMFile::IndexFile  )  const [inline]
 

Gets name of the .hhk file in the archive that could potentially be used to generate content information from.

Returns:
The index file name, with a '/' added in front and relative to the root of the archive filesystem. If no .chm has been opened, the return value is an empty string.

bool CHMFile::IndexSearch const wxString &  text,
bool  wholeWords,
bool  titlesOnly,
CHMSearchResults *  results
 

Fast search using the $FIftiMain file in the .chm.

Parameters:
text The text we're looking for.
wholeWords Are we looking for whole words only?
titlesOnly Are we looking for titles only?
results A string-string hashmap that will hold the results in case of successful search. The keys are the URLs and the values are the page titles.
Returns:
true if the search succeeded, false otherwise.

bool CHMFile::IsOk  )  const [inline]
 

Checks if the last attempt to load a .chm file was succesful.

Returns:
true, if the last attempt to load a .chm file was succesful, false otherwise.

bool CHMFile::IsValidCID const int  contextID  ) 
 

Checks whether or not the context ID is valid for the loaded file.

Parameters:
contextID The context-ID to check.
Returns:
TRUE if the context ID is valid. FALSE otherwise.

bool CHMFile::LoadCHM const wxString &  archiveName  ) 
 

Attempts to load a .chm file from disk.

Parameters:
archiveName The .chm filename on disk.
Returns:
true on success, false on failure.

bool CHMFile::LoadContextIDs  ) 
 

Attempts to build an index of context-ID/page pairs from the file.

Returns:
true if it's possible to buld the tree, false otherwise.

bool CHMFile::ResolveObject const wxString &  fileName,
chmUnitInfo *  ui
 

Looks up fileName in the archive.

Parameters:
fileName The file name to look up in the archive, qualified with '/' standing for the root of the archive filesystem.
ui A pointer to CHMLIB specific data about the file. The parameter gets filled with useful data if the lookup was succesful.
Returns:
true if the file exists in the archive, false otherwise.

size_t CHMFile::RetrieveObject chmUnitInfo *  ui,
unsigned char *  buffer,
off_t  fileOffset,
size_t  bufferSize
 

Retrieves an uncompressed chunk of a file in the .chm.

Parameters:
ui Pointer to a CHMLIB specific data structure obtained from a succesful call to ResolveObject().
buffer The buffer to place the chunk into.
fileOffset Where does the chunk we want begin in the file?
bufferSize The size of the buffer.
Returns:
0 on error, length of chunk retrieved otherwise.

wxString CHMFile::Title  )  const [inline]
 

Gets the name of the opened .chm.

Returns:
The name of the opened document, or an empty string if no .chm has been loaded.

wxString CHMFile::TopicsFile  )  const [inline]
 

Gets name of the .hhc file in the archive that could potentially be used to generate content information from.

Returns:
The topics file name, with a '/' added in front and relative to the root of the archive filesystem. If no .chm has been opened, the return value is an empty string.


The documentation for this class was generated from the following files:
Generated on Mon May 22 12:43:42 2006 for xCHM by  doxygen 1.4.4