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

fixed ToC processing

This commit is contained in:
Nikolay Pultsin 2012-05-15 11:52:21 +01:00
parent f2e3ec218b
commit 49d3f2bfe5
4 changed files with 16 additions and 7 deletions

View file

@ -1,3 +1,7 @@
===== 1.5.1 (May ??, 2012) =====
* Fixed pt/px measured font size processing for CSS's
* Fixed ToC in some ePubs (e.g. for ePubs from project Gutenberg)
===== 1.5 (May 13, 2012) ===== ===== 1.5 (May 13, 2012) =====
* New faster engine got ePub files * New faster engine got ePub files
* Improved cover support for ePubs * Improved cover support for ePubs

View file

@ -216,7 +216,7 @@ void OEBBookReader::generateTOC(const XHTMLReader &xhtmlReader) {
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(xhtmlReader.fileAlias(point.ContentHRef)).ParagraphNumber; int index = myModelReader.model().label(xhtmlReader.normalizedReference(point.ContentHRef)).ParagraphNumber;
while (level > point.Level) { while (level > point.Level) {
myModelReader.endContentsParagraph(); myModelReader.endContentsParagraph();
--level; --level;

View file

@ -349,12 +349,7 @@ void XHTMLTagHyperlinkAction::doAtStart(XHTMLReader &reader, const char **xmlatt
if (link[0] == '#') { if (link[0] == '#') {
link = reader.myReferenceAlias + link; link = reader.myReferenceAlias + link;
} else { } else {
const size_t index = link.find('#'); link = reader.normalizedReference(reader.myReferenceDirName + link);
if (index == std::string::npos) {
link = reader.fileAlias(reader.myReferenceDirName + link);
} else {
link = reader.fileAlias(reader.myReferenceDirName + link.substr(0, index)) + link.substr(index);
}
} }
} }
myHyperlinkStack.push(hyperlinkType); myHyperlinkStack.push(hyperlinkType);
@ -687,6 +682,15 @@ bool XHTMLReader::processNamespaces() const {
return true; return true;
} }
const std::string XHTMLReader::normalizedReference(const std::string &reference) const {
const size_t index = reference.find('#');
if (index == std::string::npos) {
return fileAlias(reference);
} else {
return fileAlias(reference.substr(0, index)) + reference.substr(index);
}
}
const std::string &XHTMLReader::fileAlias(const std::string &fileName) const { const std::string &XHTMLReader::fileAlias(const std::string &fileName) const {
std::map<std::string,std::string>::const_iterator it = myFileNumbers.find(fileName); std::map<std::string,std::string>::const_iterator it = myFileNumbers.find(fileName);
if (it != myFileNumbers.end()) { if (it != myFileNumbers.end()) {

View file

@ -62,6 +62,7 @@ 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);
const std::string &fileAlias(const std::string &fileName) const; const std::string &fileAlias(const std::string &fileName) const;
const std::string normalizedReference(const std::string &reference) const;
private: private:
void startElementHandler(const char *tag, const char **attributes); void startElementHandler(const char *tag, const char **attributes);