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:
parent
f2e3ec218b
commit
49d3f2bfe5
4 changed files with 16 additions and 7 deletions
|
@ -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) =====
|
||||
* New faster engine got ePub files
|
||||
* Improved cover support for ePubs
|
||||
|
|
|
@ -216,7 +216,7 @@ void OEBBookReader::generateTOC(const XHTMLReader &xhtmlReader) {
|
|||
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(xhtmlReader.fileAlias(point.ContentHRef)).ParagraphNumber;
|
||||
int index = myModelReader.model().label(xhtmlReader.normalizedReference(point.ContentHRef)).ParagraphNumber;
|
||||
while (level > point.Level) {
|
||||
myModelReader.endContentsParagraph();
|
||||
--level;
|
||||
|
|
|
@ -349,12 +349,7 @@ void XHTMLTagHyperlinkAction::doAtStart(XHTMLReader &reader, const char **xmlatt
|
|||
if (link[0] == '#') {
|
||||
link = reader.myReferenceAlias + link;
|
||||
} else {
|
||||
const size_t index = link.find('#');
|
||||
if (index == std::string::npos) {
|
||||
link = reader.fileAlias(reader.myReferenceDirName + link);
|
||||
} else {
|
||||
link = reader.fileAlias(reader.myReferenceDirName + link.substr(0, index)) + link.substr(index);
|
||||
}
|
||||
link = reader.normalizedReference(reader.myReferenceDirName + link);
|
||||
}
|
||||
}
|
||||
myHyperlinkStack.push(hyperlinkType);
|
||||
|
@ -687,6 +682,15 @@ bool XHTMLReader::processNamespaces() const {
|
|||
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 {
|
||||
std::map<std::string,std::string>::const_iterator it = myFileNumbers.find(fileName);
|
||||
if (it != myFileNumbers.end()) {
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
XHTMLReader(BookReader &modelReader);
|
||||
bool readFile(const ZLFile &file, const std::string &referenceName);
|
||||
const std::string &fileAlias(const std::string &fileName) const;
|
||||
const std::string normalizedReference(const std::string &reference) const;
|
||||
|
||||
private:
|
||||
void startElementHandler(const char *tag, const char **attributes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue