1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 02:39:23 +02:00

fixed TOC processing in ePubs

This commit is contained in:
Nikolay Pultsin 2012-05-13 14:03:15 +01:00
parent 9b22b0743a
commit 362bec72eb
4 changed files with 8 additions and 7 deletions

View file

@ -9,7 +9,7 @@ litres: author photos
* the SJ book: * the SJ book:
** empty pages at start (in emulator) ** empty pages at start (in emulator)
DONE hyperlinks (including button image) DONE hyperlinks (including button image)
** TOC!!! DONE TOC!!!
* Network library initialization in ProcessHyperlinkAction :( * Network library initialization in ProcessHyperlinkAction :(
* "Use embedded fonts" option * "Use embedded fonts" option
* "Scan hidden directories" option * "Scan hidden directories" option

View file

@ -167,12 +167,12 @@ bool OEBBookReader::readBook(const ZLFile &file) {
firstFile = false; firstFile = false;
} }
generateTOC(); generateTOC(xhtmlReader);
return true; return true;
} }
void OEBBookReader::generateTOC() { void OEBBookReader::generateTOC(const XHTMLReader &xhtmlReader) {
if (!myNCXTOCFileName.empty()) { if (!myNCXTOCFileName.empty()) {
NCXReader ncxReader(myModelReader); NCXReader ncxReader(myModelReader);
if (ncxReader.readDocument(ZLFile(myFilePrefix + myNCXTOCFileName))) { if (ncxReader.readDocument(ZLFile(myFilePrefix + myNCXTOCFileName))) {
@ -181,7 +181,7 @@ void OEBBookReader::generateTOC() {
size_t level = 0; size_t level = 0;
for (std::map<int,NCXReader::NavPoint>::const_iterator it = navigationMap.begin(); it != navigationMap.end(); ++it) { for (std::map<int,NCXReader::NavPoint>::const_iterator it = navigationMap.begin(); it != navigationMap.end(); ++it) {
const NCXReader::NavPoint &point = it->second; const NCXReader::NavPoint &point = it->second;
int index = myModelReader.model().label(point.ContentHRef).ParagraphNumber; int index = myModelReader.model().label(xhtmlReader.fileAlias(point.ContentHRef)).ParagraphNumber;
while (level > point.Level) { while (level > point.Level) {
myModelReader.endContentsParagraph(); myModelReader.endContentsParagraph();
--level; --level;

View file

@ -28,6 +28,8 @@
#include "../../bookmodel/BookReader.h" #include "../../bookmodel/BookReader.h"
class XHTMLReader;
class OEBBookReader : public ZLXMLReader { class OEBBookReader : public ZLXMLReader {
public: public:
@ -41,7 +43,7 @@ private:
void namespaceListChangedHandler(); void namespaceListChangedHandler();
const std::vector<std::string> &externalDTDs() const; const std::vector<std::string> &externalDTDs() const;
void generateTOC(); void generateTOC(const XHTMLReader &xhtmlReader);
private: private:
enum ReaderState { enum ReaderState {

View file

@ -61,10 +61,9 @@ private:
public: public:
XHTMLReader(BookReader &modelReader); XHTMLReader(BookReader &modelReader);
bool readFile(const ZLFile &file, const std::string &referenceName); bool readFile(const ZLFile &file, const std::string &referenceName);
private:
const std::string &fileAlias(const std::string &fileName) const; const std::string &fileAlias(const std::string &fileName) const;
private:
void startElementHandler(const char *tag, const char **attributes); void startElementHandler(const char *tag, const char **attributes);
void endElementHandler(const char *tag); void endElementHandler(const char *tag);
void characterDataHandler(const char *text, size_t len); void characterDataHandler(const char *text, size_t len);