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:
parent
9b22b0743a
commit
362bec72eb
4 changed files with 8 additions and 7 deletions
2
TODO.1.5
2
TODO.1.5
|
@ -9,7 +9,7 @@ litres: author photos
|
|||
* the SJ book:
|
||||
** empty pages at start (in emulator)
|
||||
DONE hyperlinks (including button image)
|
||||
** TOC!!!
|
||||
DONE TOC!!!
|
||||
* Network library initialization in ProcessHyperlinkAction :(
|
||||
* "Use embedded fonts" option
|
||||
* "Scan hidden directories" option
|
||||
|
|
|
@ -167,12 +167,12 @@ bool OEBBookReader::readBook(const ZLFile &file) {
|
|||
firstFile = false;
|
||||
}
|
||||
|
||||
generateTOC();
|
||||
generateTOC(xhtmlReader);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OEBBookReader::generateTOC() {
|
||||
void OEBBookReader::generateTOC(const XHTMLReader &xhtmlReader) {
|
||||
if (!myNCXTOCFileName.empty()) {
|
||||
NCXReader ncxReader(myModelReader);
|
||||
if (ncxReader.readDocument(ZLFile(myFilePrefix + myNCXTOCFileName))) {
|
||||
|
@ -181,7 +181,7 @@ void OEBBookReader::generateTOC() {
|
|||
size_t level = 0;
|
||||
for (std::map<int,NCXReader::NavPoint>::const_iterator it = navigationMap.begin(); it != navigationMap.end(); ++it) {
|
||||
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) {
|
||||
myModelReader.endContentsParagraph();
|
||||
--level;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include "../../bookmodel/BookReader.h"
|
||||
|
||||
class XHTMLReader;
|
||||
|
||||
class OEBBookReader : public ZLXMLReader {
|
||||
|
||||
public:
|
||||
|
@ -41,7 +43,7 @@ private:
|
|||
void namespaceListChangedHandler();
|
||||
const std::vector<std::string> &externalDTDs() const;
|
||||
|
||||
void generateTOC();
|
||||
void generateTOC(const XHTMLReader &xhtmlReader);
|
||||
|
||||
private:
|
||||
enum ReaderState {
|
||||
|
|
|
@ -61,10 +61,9 @@ private:
|
|||
public:
|
||||
XHTMLReader(BookReader &modelReader);
|
||||
bool readFile(const ZLFile &file, const std::string &referenceName);
|
||||
|
||||
private:
|
||||
const std::string &fileAlias(const std::string &fileName) const;
|
||||
|
||||
private:
|
||||
void startElementHandler(const char *tag, const char **attributes);
|
||||
void endElementHandler(const char *tag);
|
||||
void characterDataHandler(const char *text, size_t len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue