#include <chmfile.h>
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. | |
CHMFile & | operator= (const CHMFile &) |
No assignments. | |
Private Attributes | |
chmFile * | _chmFile |
wxString | _filename |
wxString | _home |
wxString | _topicsFile |
wxString | _indexFile |
wxString | _title |
wxString | _font |
wxFontEncoding | _enc |
CHMIDMap | _cidMap |
CHMFile::CHMFile | ( | const wxString & | archiveName | ) |
wxString CHMFile::ArchiveName | ( | ) | const [inline] |
Gets the filename of the currently opened .chm file.
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.
wxString CHMFile::DefaultFont | ( | ) | const [inline] |
Determines the font to use for special charsets.
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().
Referenced by CHMFrame::UpdateCHMInfo().
bool CHMFile::GetIndex | ( | CHMListCtrl * | toBuild | ) |
Attempts to fill a CHMListCtrl by parsing the index file.
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. |
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.
contextID | The context-ID to look up |
Referenced by CHMFrame::LoadContextID().
bool CHMFile::GetTopicsTree | ( | wxTreeCtrl * | toBuild | ) |
Attempts to fill a wxTreeCtrl by parsing the topics file.
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. |
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.
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.
bool CHMFile::IndexSearch | ( | const wxString & | text, | |
bool | wholeWords, | |||
bool | titlesOnly, | |||
CHMSearchResults * | results | |||
) |
Fast search using the $FIftiMain file in the .chm.
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. |
References GetLeafNodeOffset(), and ProcessWLC().
bool CHMFile::IsOk | ( | ) | const [inline] |
Checks if the last attempt to load a .chm file was succesful.
Referenced by CHMInputStream::Init().
bool CHMFile::IsValidCID | ( | const int | contextID | ) |
Checks whether or not the context ID is valid for the loaded file.
contextID | The context-ID to check. |
Referenced by CHMFrame::LoadContextID().
bool CHMFile::LoadCHM | ( | const wxString & | archiveName | ) |
Attempts to load a .chm file from disk.
archiveName | The .chm filename on disk. |
References CloseCHM(), GetArchiveInfo(), and LoadContextIDs().
Referenced by CHMFile().
bool CHMFile::LoadContextIDs | ( | ) |
Attempts to build an index of context-ID/page pairs from the file.
Referenced by LoadCHM().
bool CHMFile::ResolveObject | ( | const wxString & | fileName, | |
chmUnitInfo * | ui | |||
) |
Looks up fileName in the archive.
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. |
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.
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. |
Referenced by GetIndex(), GetTopicsTree(), and CHMInputStream::OnSysRead().
wxString CHMFile::Title | ( | ) | const [inline] |
Gets the name of the opened .chm.
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.