112
115
//---------------------------------------------------------------------------------------
113
// lmPageIndexItem: an entry of the page index table
116
// PageIndexItem: an entry of the page index table
114
117
// The page index is a global table with all the html pages available. It is used to
115
118
// search for a page. This table is needed as all other tables only contains
116
119
// information about the pages that are in a book's TOC
117
struct lmPageIndexItem
119
lmPageIndexItem() : page(wxEmptyString), book(wxEmptyString) {}
122
PageIndexItem() : page(wxEmptyString), book(wxEmptyString) {}
121
124
wxString page; // html page to display
122
125
wxString book; // book path
164
167
//// State information of a search action. I'd have preferred to make this a
165
//// nested class inside BookReader, but that's against coding standards :-(
168
//// nested class inside BooksCollection, but that's against coding standards :-(
166
169
//// Never construct this class yourself, obtain a copy from
167
//// BookReader::PrepareKeywordSearch(const wxString& key)
170
//// BooksCollection::PrepareKeywordSearch(const wxString& key)
168
171
//class lmSearchStatus
171
// // constructor; supply BookReader ptr, the keyword and (optionally) the
174
// // constructor; supply BooksCollection ptr, the keyword and (optionally) the
172
175
// // title of the book to search. By default, all books are searched.
173
// lmSearchStatus(BookReader* base, const wxString& keyword,
176
// lmSearchStatus(BooksCollection* base, const wxString& keyword,
174
177
// bool case_sensitive, bool whole_words_only,
175
178
// const wxString& book = wxEmptyString);
176
179
// bool Search(); // do the next iteration
199
202
//---------------------------------------------------------------------------------------
200
// Class BookReader contains the information about all loaded books
203
// Class BooksCollection contains the information about all loaded books
204
class BooksCollection
203
// friend class lmSearchStatus;
205
bool AddBookPagesToList(const wxFileName& oFilename);
206
bool ProcessIndexFile(const wxFileName& oFilename, BookRecord* pBookr);
207
void ProcessIndexEntries(wxXmlNode* pNode, BookRecord *pBookr);
208
bool ProcessTOCEntry(wxXmlNode* pNode, BookRecord *pBookr, int nLevel);
210
207
wxString m_tempPath;
211
XmlParser* m_pParser;
212
BookRecArray m_bookRecords; // each book has one record in this array
213
BookIndexArray m_contents; // list of all available books and their TOCs
214
BookIndexArray m_index; // list of all index items
215
lmPageIndexArray m_pagelist; // list of all html pages (whether in TOC or not in TOC)
208
XmlParser* m_pParser;
209
BookRecArray m_bookRecords; // each book has one record in this array
210
BookIndexArray m_contents; // list of all available books and their TOCs
211
BookIndexArray m_index; // list of all index items
212
lmPageIndexArray m_pagelist; // list of all pages (whether in TOC or not in TOC)
213
map<wxString, wxZipEntry*> m_bookEntries;
217
DECLARE_NO_COPY_CLASS(BookReader)
215
DECLARE_NO_COPY_CLASS(BooksCollection)
223
221
void SetTempDir(const wxString& path);
225
223
// Adds new book.
226
bool AddBook(const wxFileName& book);
224
BookRecord* add_book(const wxFileName& book);
228
226
// Page search methods
229
wxString FindPageByName(const wxString& page);
227
wxString find_page_by_name(const wxString& page);
230
228
wxString FindPageById(int id);
232
230
// accessors to the tables
233
231
inline const BookRecArray& GetBookRecArray() const { return m_bookRecords; }
234
232
inline const BookIndexArray& GetContentsArray() const { return m_contents; }
235
233
inline const BookIndexArray& GetIndexArray() const { return m_index; }
237
BookRecord* ProcessTOCFile(const wxFileName& oFilename);
234
wxString get_path_for_toc_item(int item);
238
bool add_pages_to_list(const wxFileName& oFilename);
239
BookRecord* add_book_toc(const wxFileName& oFilename);
240
bool ProcessTOCEntry(wxXmlNode* pNode, BookRecord *pBookr, int nLevel);
242
void determine_book_format(wxZipInputStream& zip);
243
bool add_lms_pages(wxZipInputStream& zip, const wxString& sBookPath);
244
bool add_lmd_pages(wxZipInputStream& zip, const wxString& sBookPath);
246
void load_book_entries(wxZipInputStream& zip);
247
wxZipEntry* find_entry(const wxString& name);
248
void delete_book_entries();
254
k_format_0, //old style, LMS files
255
k_format_1, //new style, LMD files
260
//---------------------------------------------------------------------------------------
261
// Class BookReader: Understands book format and knows how to get its content.