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 (uint32_t lcid)
 Helper. Translates from MS-specific LCID.
bool GetArchiveInfo ()
 Helper. Initializes most of the private data members.
uint32_t GetLeafNodeOffset (const wxString &text, uint32_t initalOffset, uint32_t buffSize, uint16_t treeDepth, chmUnitInfo *ui)
 Helper. Returns the $FIftiMain offset of leaf node or 0.
bool ProcessWLC (uint64_t wlc_count, uint64_t wlc_size, uint32_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.
bool BinaryTOC (wxTreeCtrl *toBuild, const wxCSConv &cv)
 Load binary TOC (if available).
void RecurseLoadBTOC (UCharPtr &topidx, UCharPtr &topics, UCharPtr &strings, UCharPtr &urltbl, UCharPtr &urlstr, uint32_t offset, const wxCSConv &cv, wxTreeCtrl *toBuild, int level)
 Try to recursively load the binary topics tree.
bool GetItem (UCharPtr &topics, UCharPtr &strings, UCharPtr &urltbl, UCharPtr &urlstr, uint32_t index, wxTreeCtrl *tree, CHMListCtrl *list, const wxString &idxName, int level, bool local)
 Retrieve the data (name/URL) for a single entry (TOC or index).
bool BinaryIndex (CHMListCtrl *toBuild, const wxCSConv &cv)
 Get the binary index (if available).
bool ConvertFromUnicode (std::string &value, unsigned char *buffer, size_t bufferLength)
 Get a regular string from a generic buffer of length bufferLength.
 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.

References LoadCHM().


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.

Referenced by CHMInputStream::Init(), CHMFrame::LoadBookmarks(), CHMFrame::LoadCHM(), CHMFrame::LoadContextID(), CHMListCtrl::LoadSelected(), CHMFrame::OnBookmarkSel(), CHMFrame::OnSelectionChanged(), CHMSearchPanel::PopulateList(), CHMFrame::SaveBookmarks(), and CHMFrame::UpdateCHMInfo().

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.

Referenced by CHMFrame::UpdateCHMInfo().

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.

Referenced by CHMFrame::UpdateCHMInfo().

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.

References BinaryIndex(), HHCParser::parse(), ResolveObject(), and RetrieveObject().

Referenced by CHMFrame::UpdateCHMInfo().

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.

Referenced by CHMFrame::LoadContextID().

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.

References BinaryTOC(), HHCParser::parse(), ResolveObject(), and RetrieveObject().

Referenced by CHMFrame::UpdateCHMInfo().

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 "/".

Referenced by CHMInputStream::CHMInputStream(), and CHMFrame::LoadCHM().

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.

References GetLeafNodeOffset(), and ProcessWLC().

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.

Referenced by CHMInputStream::Init().

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.

Referenced by CHMFrame::LoadContextID().

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.

References CloseCHM(), GetArchiveInfo(), and LoadContextIDs().

Referenced by CHMFile().

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.

Referenced by LoadCHM().

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.

Referenced by CHMInputStream::CHMInputStream(), GetIndex(), and GetTopicsTree().

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.

Referenced by GetIndex(), GetTopicsTree(), and CHMInputStream::OnSysRead().

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.

Referenced by CHMFrame::UpdateCHMInfo().

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 Wed Oct 28 17:35:58 2009 for xCHM by  doxygen 1.5.8